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
➜ I suppose this is an elseif question.
|
I suppose this is an elseif question.
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Ahiram
(14 posts) Bio
|
| Date
| Sun 27 Mar 2011 01:07 AM (UTC) |
| Message
| I think this is solved with an if, but I'm clearly doing something wrong.
<alias
match="^x(.*)(.*)(.*)$"
enabled="y"
expand_variables="y"
regexp="y"
send_to="12"
sequence="100">
<send>if "%1" == "1" then Send ("kick1")
elseif "%1" == "2" then Send ("kick2")
elseif "%1" == "3" then Send ("kick3")
and
if "%2" == "1" then Send ("punch1")
elseif "%2" == "2" then Send ("punch2")
elseif "%2" == "3" then Send ("punch3")
and
if "%3" == "1" then Send ("punch1")
elseif "%3" == "2" then Send ("punch2")
elseif "%3" == "3" then Send ("punch3")
end</send></alias>
The idea is that I can make up combos on the fly. So x311 would kick the person in the right arm, then punch them twice in the left. Does not work. My first try was to have multiple aliases, but that gave no response at all. The above gave a response. That response just happened to be:
Compile error
Plugin: Sandbox (called from world: Achaea)
Immediate execution
[string "Alias: "]:4: unexpected symbol near 'and'
I have a feeling the solution is agonizingly simple, I just don't know what it is. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Sun 27 Mar 2011 02:24 AM (UTC) |
| Message
| Just change the two "and" to "end" and it should work. After all, the 3 ifs are independent aren't they?
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Manacle
(28 posts) Bio
|
| Date
| Reply #2 on Sun 27 Mar 2011 02:26 AM (UTC) |
| Message
| I don't generally script inside aliases, so I don't know if you're pulling the wildcards correctly, but I can see a few problems.
This:
if "%1" == "1" then Send ("kick1")
elseif "%1" == "2" then Send ("kick2")
elseif "%1" == "3" then Send ("kick3")
should end with an "end" statement like this:
if "%1" == "1" then Send ("kick1")
elseif "%1" == "2" then Send ("kick2")
elseif "%1" == "3" then Send ("kick3")
end
Get rid of the "and". You're using "and" as if you're telling the script "do this AND this AND this", but that's not right -- the script will do everything you ask it to do in order anyway. So try:
if "%1" == "1" then Send ("kick1")
elseif "%1" == "2" then Send ("kick2")
elseif "%1" == "3" then Send ("kick3")
end
if "%2" == "1" then Send ("punch1")
elseif "%2" == "2" then Send ("punch2")
elseif "%2" == "3" then Send ("punch3")
end
if "%3" == "1" then Send ("punch1")
elseif "%3" == "2" then Send ("punch2")
elseif "%3" == "3" then Send ("punch3")
end
Also, you may wish to clean up your regular expression. The one you're using now isn't quite what you actually mean, I think. The expression "(.*)" means to match an infinitely large number of arbitrary characters, but I think you mean to only match three in a row. Try this:
^x(.)(.)(.)$
This will prevent small problems if you mistype or something like this. | | Top |
|
| Posted by
| Ahiram
(14 posts) Bio
|
| Date
| Reply #3 on Sun 27 Mar 2011 07:09 AM (UTC) |
| Message
| | Perfect on both counts. Thanks, guys. | | 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.
15,727 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top