I suppose this is an elseif question.

Posted by Ahiram on Sun 27 Mar 2011 01:07 AM — 4 posts, 17,344 views.

#0
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.
Australia Forum Administrator #1
Just change the two "and" to "end" and it should work. After all, the 3 ifs are independent aren't they?
#2
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.
#3
Perfect on both counts. Thanks, guys.