Gammon Forum
Entire forum
MUSHclient
Lua
Simple trigger if/then help
Simple trigger if/then help
|
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| ShatterMelon
(4 posts) bio
|
Date
| Wed 22 Jan 2014 03:48 PM (UTC) Amended on Thu 23 Jan 2014 11:05 PM (UTC) by Nick Gammon
|
Message
| Hello all,
I'm hoping someone can help me figure out this if/then trigger I am trying to make work. I have a feeling I'm mixing scripting languages (but I am trying to use Lua, I believe) when I'm trying to do this, so any help/direction would be appreciated.
This is the trigger I am trying to use:
<triggers>
<trigger
group="Hunt"
keep_evaluating="y"
match="^Also here: (an|a) ([^,]*?), and Shazbo the Human"
regexp="y"
send_to="12"
sequence="100"
>
<send>If "%2" = "@nokill" Then
Send "0"
Else
Send "command"
Endif</send>
</trigger>
</triggers>
I feel like this is wrong and won't work correctly? Effectively, I want the trigger to look at the MOB name after (a|an), and if it is part of variable table @nokill, then it should do nothing, but if nothing in the variable table @nokill is matched, then it should send a command targeted at the MOB.
Any help is much appreciated! Thank you. | top |
|
Posted by
| Nick Gammon
Australia (22,975 posts) bio
Forum Administrator |
Date
| Reply #1 on Thu 23 Jan 2014 11:07 PM (UTC) |
Message
| You are using VB syntax but you acknowledge it is Lua.
The Lua operators (like "if") are not capitalised.
Closer is:
if "%2" == "@nokill" then
Send "0"
else
Send "command"
end
I don't know why you want to send "0" to the MUD, but I guess this is just an example. Nor why you want to send "command".
I suggest you read some of the Lua tutorials, for example:
http://www.lua.org/pil/
The older ones are available online and are relevant as far as the basic syntax goes. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| ShatterMelon
(4 posts) bio
|
Date
| Reply #2 on Sun 26 Jan 2014 11:33 PM (UTC) |
Message
| Hi and thanks for the suggestions! Sadly, it is not working. Below is the actual trigger I am attempting and the error I receive. Again, the main purpose is to view a MOB in the room, and if it is not on the nokill variable list, attack it. If it is on the list, then do not attack the MOB. If there is a more effective way of checking for this than the if/then trigger I am attempting, that suggestion would also be welcome.
Thanks!
<triggers>
<trigger
expand_variables="y"
group="Hunt"
keep_evaluating="y"
match="^Also here: (an|a) ([^,]*?)$"
regexp="y"
send_to="12"
sequence="100"
>
<send>if "%2" == "@nokill" then
Send ("who")
else
Send ("c current %2")
end -- if</send>
</trigger>
</triggers>
Error number: -2146827286
Event: Execution of line 1 column 37
Description: Syntax error
Line in error:
if "animated stone knight statue " == "little forest mouse" then
Called by: Immediate execution | top |
|
Posted by
| Salina
(1 post) bio
|
Date
| Reply #3 on Sat 01 Feb 2014 09:50 AM (UTC) |
Message
| it won't work due to inability to send aliases recursively. So right now, I got something going using tells to the other chars but that's so kludgy, though, it works. |
salina | top |
|
Posted by
| Nick Gammon
Australia (22,975 posts) bio
Forum Administrator |
Date
| Reply #4 on Sun 02 Feb 2014 07:42 PM (UTC) |
Message
|
Error number: -2146827286
That doesn't look like a Lua error message. First thing is to find which language you are using, don't guess.
Configuration -> Scripting -> Scripts
That will tell you. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| ShatterMelon
(4 posts) bio
|
Date
| Reply #5 on Fri 07 Feb 2014 09:42 PM (UTC) |
Message
| Apparently I still had my script setting in VBScript. It works when I swapped it to Lua, but it still will not compare the wildcard "%2" to a stored list defined under "@nokill"
Using
<triggers>
<trigger
enabled="y"
expand_variables="y"
group="Hunt"
keep_evaluating="y"
match="^Also here: Shazbo the Human, and (an|a) ([^,]*?)$"
regexp="y"
send_to="12"
sequence="100"
>
<send>if "@nokill" ~= "%2" then
Send ("c current %2")
end</send>
</trigger>
</triggers>
Will only work if I have only ONE mob listed in the @nokill variable.
<variables>
<variable name="nokill">little forest mouse</variable>
</variables>
The above works. However, I need it to compare against a variable list like this:
<variables>
<variable name="nokill">little forest mouse|old woodsman|animated stone knight statue|animated granite archer statue|animated marble sorcerer statue</variable>
</variables>
In which case, the attack still fires and appears to disregard the inclusion of the MOB in the list. | top |
|
Posted by
| Nick Gammon
Australia (22,975 posts) bio
Forum Administrator |
Date
| Reply #6 on Sun 09 Feb 2014 12:14 AM (UTC) |
Message
| A straight compare like this will not work for a list:
What this will expand to is:
if "little forest mouse|old woodsman|animated stone knight statue|..." ~= "little forest mouse"
Clearly they are not the same.
You could split up the list (putting the results into a table) and then see if the item in question is in the table. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| ShatterMelon
(4 posts) bio
|
Date
| Reply #7 on Sun 09 Feb 2014 05:39 AM (UTC) |
Message
| Oh, thank you. I thought I was making a variable table by writing the monster names separated by |. How would I go about properly comparing with the list, or making and calling the table? | top |
|
Posted by
| Nick Gammon
Australia (22,975 posts) bio
Forum Administrator |
Date
| Reply #8 on Mon 10 Feb 2014 06:10 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.
21,356 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
top
Quick links:
MUSHclient.
MUSHclient help.
Forum shortcuts.
Posting templates.
Lua modules.
Lua documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.