[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  Help with "if" and variables. please
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Help with "if" and variables. please
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Larkin   (278 posts)  [Biography] bio
Date Sat 09 Jul 2005 07:24 PM (UTC)  quote  ]
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.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Sat 09 Jul 2005 04:12 AM (UTC)  quote  ]
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.
[Go to top] top

Posted by Larkin   (278 posts)  [Biography] bio
Date Sat 09 Jul 2005 02:50 AM (UTC)  quote  ]
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.
[Go to top] top

Posted by Hoss   USA  (48 posts)  [Biography] bio
Date Fri 08 Jul 2005 07:47 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Mon 30 May 2005 06:26 AM (UTC)  quote  ]
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.
[Go to top] top

Posted by Lucano   (2 posts)  [Biography] bio
Date Mon 30 May 2005 03:44 AM (UTC)  quote  ]
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

[Go to top] 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.


3,213 views.

It is now over 60 days since the last post. This thread is closed.   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Web site powered by FutureQuest.Net]