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 ➜ Help with "if" and variables. please

Help with "if" and variables. please

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


Posted by Lucano   (2 posts)  Bio
Date Mon 30 May 2005 03:44 AM (UTC)
Message
What I want to do is a trigger, so when I get the message

^Hmmmm. Why must everything be so difficult to figure out?$

I set the variable stupidity to 1 and if eatcan is 1 I can eat the herb, so I set eatcan to 0, then get the herb, eat and eat it. After that the cure line will set stupidity to 0 again. Is this correct?

world.setvariable "stupidity", "1"
if world.getvariable ("eatcan") = "1" then
world.setvariable "eatcan", "0"
world.execute "outr 1 goldenseal"
world.execute "eat goldenseal"
end if

Thanks in advance

Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #1 on Mon 30 May 2005 06:26 AM (UTC)
Message
That won't set stupidity to 0. But I'm assuming you're not expecting it to (you have another trigger or an alias to do that for you).

If you don't need the things you're sending to be evaluated (for aliases) then you can (and probably should) use world.send instead of world.execute.

You may also want to set the variables to 0 and 1 (instead of "0" and "1") and then test against 0 and 1 (again instead of their string counterparts).

And, if you are using a regular expression for your trigger, you'll need to escape the question mark and the period (with a backslash):
^Hmmmm\. Why must everything be so difficult to figure out\?$

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Hoss   USA  (48 posts)  Bio
Date Reply #2 on Fri 08 Jul 2005 07:47 PM (UTC)
Message

world.setvariable "stupidity", "1"
if world.getvariable("eatcan") = "1" then
world.setvariable "eatcan", "0"
world.send "outr 1 goldenseal"
world.send "eat goldenseal"
world.setvariable "stupidity", "0"
end if


That's what you want all I changed was the world.executes to world.send and added world.setvariable this wasy it'll set "stupidity" to 1 then if "eatcan" is equal to 1 it'll set eatcan to 0 get the goldenseal and then eat it and then set "stupidity" back to 0 also make the changes that Flannel said about your reg expression
Top

Posted by Larkin   (278 posts)  Bio
Date Reply #3 on Sat 09 Jul 2005 02:50 AM (UTC)
Message
Execute should work just as well for what he's doing, unless he's got alias matches that he doesn't want to trigger. From what I've seen, the only difference between the two functions is that Execute will be parsed by the aliases and Send bypasses the aliases to go directly to the game.

You don't want to set your stupidity variable to 0 when you attempt the cure. You should have a trigger for the cure and set it to 0 then, especially with an affliction like stupidity which can often screw up your curing.
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #4 on Sat 09 Jul 2005 04:12 AM (UTC)
Message
You should use send when you want to send it to the server. Using execute just wastes time (while going through the aliases) which might not sound like a lot for each triiger/alias, it all adds up. Especially when you're sending multiple lines per trigger.
Apart from that, using execute for most/all/by default makes it really easy to get yourself into infinite loops. Whether it's within a single alias, or whether down the road you change/add something, and then you find yourself in a loop, which will be even more difficult to get rid of.

So, danger of loops, and the extra time using Executes, both make using send by default (and using executes only when you need to) a good practice to get in to.

(And then the pure laziness factor, in which you can just type "send" but in VB you have to type out "World.execute" to get around the VB function)

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Larkin   (278 posts)  Bio
Date Reply #5 on Sat 09 Jul 2005 07:24 PM (UTC)
Message
I do almost the opposite, actually. I like to be able to override commands easily, so I do most commands through Execute and only use Send when I'm doing a command that would match my alias and cause one of those dreaded infinite loops. I know it's a tad slower, but coming from zMUD, it still appears to be 10 times faster. Heh.
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.


20,505 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.