[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  I suppose this is an elseif question.

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

I suppose this is an elseif question.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Ahiram   (14 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] 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
[Go to top] top

Posted by Manacle   (19 posts)  [Biography] 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.
[Go to top] top

Posted by Ahiram   (14 posts)  [Biography] bio
Date Reply #3 on Sun 27 Mar 2011 07:09 AM (UTC)  quote  ]
Message
Perfect on both counts. Thanks, guys.
[Go to top] 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]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]