|
I suppose this is an elseif question.
|
Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Ahiram
(14 posts) bio
|
| Date |
Sun 27 Mar 2011 01:07 AM (UTC) [ quote
] |
| 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 (18,770 posts) bio
Forum Administrator |
| Date |
Reply #1 on Sun 27 Mar 2011 02:24 AM (UTC) [ quote
] |
| 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
(19 posts) bio
|
| Date |
Reply #2 on Sun 27 Mar 2011 02:26 AM (UTC) [ quote
] |
| 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) [ quote
] |
| 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.
1,154 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )