Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ world.DoAfter

world.DoAfter

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Hoss   USA  (48 posts)  Bio
Date Mon 06 Dec 2004 01:26 AM (UTC)
Message
I'm working with a world.DoAfter and this is what it's going through

world.setvariable "ginp", cint(world.getvariable ("ginp")) -1

if @ginp = "20" or @ginp < "20" then
world.note "Time To Change Plants"
Elseif @ginp > "20" then
world.DoAfter 4, "hgi"
end if

But I seem to find that the DoAfter is firing once more time than it should be if it's set for 20 but if I set it for 21 it doesn't send that extra time any idea why?

Hoss
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 06 Dec 2004 06:05 AM (UTC)
Message
This code looks a bit strange.


  • There is a "less than or equal" operator (<=) so you don't need to separately test for less OR equal. Thus I would rewrite:


    if @ginp = "20" or @ginp < "20" then


    as


    if @ginp <= "20" then


  • I don't see the point in then testing for:


    Elseif @ginp > "20" then


    Surely if something is not less than or equal to 20, it must be greater than? So that can just be a straight "else".

  • You are comparing numbers to strings. I would rewrite it as:

    
    If @ginp <= 20 Then
      world.Note "Time To Change Plants"
    Else 
      world.DoAfter 4, "hgi"
    end if
    




Finally the real problem. When you use @ginp as a variable in your trigger, MUSHclient will substitute the current value of the variable "ginp" into the "send to" box, and then execute the script.

Subtracting 1 in the script itself is too late. The substitution has already been done.

What you could do instead is:



SetVariable "ginp", cint(GetVariable ("ginp")) -1

If CInt(GetVariable ("ginp")) <= 20 Then
  Note "Time To Change Plants"
Else 
  DoAfter 4, "hgi"
end if

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #2 on Mon 06 Dec 2004 06:30 AM (UTC)
Message
Or you could just account for that 1 being subracted, and compare it to 21 (which is what the variable is before you subtract, to get to 20).

You should probably subtract from the variable after the if statement, to keep yourself from being confused later.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


12,775 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.