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
➜ General
➜ Executing timed aliases gathering trigger data
Executing timed aliases gathering trigger data
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| ErockMahan
(81 posts) Bio
|
Date
| Mon 04 Oct 2010 10:36 PM (UTC) |
Message
| Bob gives me an item, which sets a variable and then executes an alias 3 seconds later (with 'doafterspecial'), but for some reason the alias does not pick up the variable change.
Is 3 seconds not long enough to register the change, or is there something fundamental about the way Mushclient works that won't allow all these things to happen without a manually executed command? | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #1 on Mon 04 Oct 2010 11:23 PM (UTC) Amended on Mon 04 Oct 2010 11:25 PM (UTC) by Twisol
|
Message
| Without seeing the alias, I can only make a guess. I think my guess is a good one, but if I'm wrong, please copy your alias and paste it here in your next post.
 |
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.
|
At any rate, I'm guessing you have something like this:
This is a little technical, but the problem is that the "@variable_name" syntax is not actually part of a scripting language. It's something MUSHclient provides on top, just like the wildcard %1 syntax. It does this by processing the script first itself, replacing %1 inline with the wildcard and @myvar inline with the variable's contents. So even before the script is actually executed, the above becomes:
As you can see, the variable was evaluated before the delayed command executes 3 seconds later. The solution is simple:
DoAfterSpecial(3, [[Send("foo " .. GetVariable("myvar"))]], send_to.script)
Note that I'm using the script function GetVariable, instead of relying on the @myvar shorthand. This ensures that it's the script itself that accesses the variable when it's supposed to, not the MUSHclient preprocessor. Also note that I'm using Lua long-style strings (the [[contents]] thing). This is just so I can use double-quotes in the delayed script; if you're using another language you'll probably do something like use "" for the delayed script and '' for the quotes inside it.
TL;DR: Use this:
DoAfterSpecial(3, [[Send("foo " .. GetVariable("myvar"))]], send_to.script)
|
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #2 on Tue 05 Oct 2010 12:13 AM (UTC) Amended on Mon 11 Oct 2010 10:57 PM (UTC) by Nick Gammon
|
Message
|
ErockMahan said:
Bob gives me an item, which sets a variable and then executes an alias 3 seconds later (with 'doafterspecial'), but for some reason the alias does not pick up the variable change.
I agree with what Twisol said, but the other thing is "what variable change"? His solution will pick up the variable at the time the delayed alias is called (which may or may not be what you want exactly - maybe the variable changes again 2 seconds later).
Also, if the thing you are doing is an alias (which you said it was) then Send is wrong, it should be Execute, like this:
DoAfterSpecial(3, 'Execute ("foo " .. GetVariable ("myvar"))', sendto.script)
(Note: sendto.script, not send_to.script).
That way "foo" is treated as an alias, and not just sent to the MUD.
However if I read your post correctly, you want to set a variable, and then use that new variable 3 seconds later. In which case this should work:
DoAfter (3, "foo " .. GetVariable ("myvar"))
This will concatenate your alias with the new contents of the variable, and then do that 3 seconds later.
However if you had (as Twisol guessed):
DoAfter (3, "foo @myvar")
Then you get the old value of the variable, not the one you just set.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| ErockMahan
(81 posts) Bio
|
Date
| Reply #3 on Mon 11 Oct 2010 05:16 PM (UTC) |
Message
| I think Nick nailed it - the problem is that I'm getting variable information with @, which doesn't pick up the changes since the original execution. I'll try "getting" the variables and see if that doesn't make the difference. | 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.
14,693 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top