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
➜ Lua
➜ How do I handle null %1 variables
How do I handle null %1 variables
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Errigour
USA (32 posts) Bio
|
Date
| Sun 24 Jul 2011 09:03 PM (UTC) Amended on Sun 24 Jul 2011 09:25 PM (UTC) by Errigour
|
Message
| I'm looking for something like The last question I asked accept it used numbers and only needed to be "heal *" but
this one is "^de( .*){0,1}$" and I can't make lua use
if %1 then <do something> else <do something else> end
if %1 then
--do extra stuff
else
--do repetitive stuff
end
or
if !%1 then
--do repetitive stuff
else
--do extra stuff
end
The following is what I am using the if statement for.
Alias:^de( .*){0,1}$
Send("cast '@castingspell'")
--I don't want this to happen if I type de by itself
--I don't want this to happen if I type de by itself
Send("cast '@castingspell' %1")
SetVariable("target", "%1")
ColourNote("#0000ff", "#FFFFFF", string.format("Target set as: %s", GetVariable("target")))
--I don't want this to happen if I type de by itself
--I don't want this to happen if I type de by itself
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sun 24 Jul 2011 09:31 PM (UTC) |
Message
| This is the third time you have asked this, and twice before I referred you to FAQ #50.
Does that not explain things well? In what way is it lacking?
Inside FAQ #50 it mentions using this:
<aliases>
<alias
match="^heal( {1,}(.*)){0,1}$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
if "%2" == "" then
Send ("cast healing touch self")
else
Send ("cast healing touch %2")
end -- if
</send>
</alias>
</aliases>
This is amazingly similar to what you are trying to do.
So to make the minor changes for your case it would be:
<aliases>
<alias
match="^de( {1,}(.*)){0,1}$"
enabled="y"
expand_variables="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
if "%2" == "" then
Send("cast '@castingspell'")
else
Send("cast '@castingspell' %1")
SetVariable("target", "%1")
ColourNote("#0000ff", "#FFFFFF",
string.format("Target set as: %s", GetVariable("target")))
end -- if
</send>
</alias>
</aliases>
 |
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
|
If you can tell me how to improve the FAQ to make it clearer I would be grateful. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Errigour
USA (32 posts) Bio
|
Date
| Reply #2 on Sun 24 Jul 2011 09:48 PM (UTC) Amended on Sun 24 Jul 2011 09:54 PM (UTC) by Errigour
|
Message
| |
Posted by
| Errigour
USA (32 posts) Bio
|
Date
| Reply #3 on Sun 24 Jul 2011 09:55 PM (UTC) |
Message
| It's hard for me to understand that stuff so I don't
soak in everything the page says but thank you. | Top |
|
Posted by
| Edwin_r
(6 posts) Bio
|
Date
| Reply #4 on Wed 25 Jul 2012 02:59 AM (UTC) |
Message
|
Nick Gammon said:
This is the third time you have asked this, and twice before I referred you to FAQ #50.
(faq=50)
Does that not explain things well? In what way is it lacking?
Inside FAQ #50 it mentions using this:
<aliases>
<alias
match="^heal( {1,}(.*)){0,1}$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
if "%2" == "" then
Send ("cast healing touch self")
else
Send ("cast healing touch %2")
end -- if
</send>
</alias>
</aliases>
This is amazingly similar to what you are trying to do.
So to make the minor changes for your case it would be:
<aliases>
<alias
match="^de( {1,}(.*)){0,1}$"
enabled="y"
expand_variables="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
if "%2" == "" then
Send("cast '@castingspell'")
else
Send("cast '@castingspell' %1")
SetVariable("target", "%1")
ColourNote("#0000ff", "#FFFFFF",
string.format("Target set as: %s", GetVariable("target")))
end -- if
</send>
</alias>
</aliases>
(pasting)
If you can tell me how to improve the FAQ to make it clearer I would be grateful.
--------------------------------
Dear Nick, i'll appreciate if you could give me an example of this code but applied to a table that contains several objects: e.g.
instead of:
Send("cast '@castingspell' %1")
i would like to:
Send ("cast '[protection|benediction|sanctuary]')
the idea it's casting all these spells, by an alias. Obviously i have no idea how to invoke that table.
Thank you so muy, i'm a completly newbie in Lua, sadly. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #5 on Wed 25 Jul 2012 03:15 AM (UTC) |
Message
| |
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.
19,516 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top