Gammon Forum
Entire forum
MUSHclient
General
Compare variables
It is now over 60 days since the last post. This thread is closed.
 
Refresh page
Posted by
| Winddancer
(26 posts) bio
|
Date
| Fri 26 May 2023 05:06 PM (UTC) |
Message
| I want to execute a command, depending on the value of a variable.
I probably am missing something here, as the following does not work:
<alias
match="v_sslam"
enabled="y"
expand_variables="y"
group="specials"
send_to="12"
omit_from_output="y"
sequence="100"
>
<send>Note ("inside " .. "@myspecialname")
Send("slam")
Send("@myelbow")
Send("knee")
Send("headbutt")
if @punch_attack == 'yes' then
Send("punch")
end
Send("kick")
</send>
Regardless wether the variable has the value yes or no, the command punch is not sent.
When I change the alias to:
<alias
match="v_sslam"
enabled="y"
expand_variables="y"
group="specials"
send_to="12"
omit_from_output="y"
sequence="100"
>
<send>Note ("inside " .. "@myspecialname")
Send("slam")
Send("@myelbow")
Send("knee")
Send("headbutt")
if @punch_attack == yes then
Send("punch")
end
Send("kick")
</send>
Regardless wether the variable has the value yes or no, the command punch is sent.
What am I doing wrong? What am I missing? | top |
|
Posted by
| Fiendish
USA (2,500 posts) bio
Global Moderator |
Date
| Reply #1 on Fri 26 May 2023 05:50 PM (UTC) Amended on Fri 26 May 2023 05:58 PM (UTC) by Fiendish
|
Message
| Missing quotation marks.
Try this instead
<alias
match="v_sslam"
enabled="y"
expand_variables="y"
group="specials"
send_to="12"
omit_from_output="y"
sequence="100"
>
<send>
Note("inside @myspecialname")
Send("slam")
Send("@myelbow")
Send("knee")
Send("headbutt")
if "@punch_attack" == "yes" then
Send("punch")
end
Send("kick")
</send>
Side note:
I always advise people that using expand_variables-style "@" notation inside the send block is a dangerous idea that everyone should get out of the habit of doing because it will at some point cause a problem.
@whatever gets set via find/replace before the code gets sent to the script engine, so anything you might set inside the code itself will not get picked up. In this specific case you're fine, but people usually don't realize this difference and then get stuck wondering why something a little more complex doesn't pick up the variables they just set.
I think everyone should get used to using SetVariable/GetVariable instead when inside a script section (send_to="12") and only use "@" expansion in match patterns (when you need an alias to match a pattern based on some variable that is set). |
https://github.com/fiendish/aardwolfclientpackage | top |
|
Posted by
| Nick Gammon
Australia (22,928 posts) bio
Forum Administrator |
Date
| Reply #2 on Wed 31 May 2023 06:11 AM (UTC) Amended on Wed 31 May 2023 06:12 AM (UTC) by Nick Gammon
|
Message
|
There might be other useful tips for you on that page as well. In your case it wasn't a wildcard, but the concept is the same. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
1,768 views.
It is now over 60 days since the last post. This thread is closed.
 
Refresh page
top
Quick links:
MUSHclient.
MUSHclient help.
Forum shortcuts.
Posting templates.
Lua modules.
Lua documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.