Simple trigger if/then help

Posted by ShatterMelon on Wed 22 Jan 2014 03:48 PM — 9 posts, 32,850 views.

#0
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.
Amended on Thu 23 Jan 2014 11:05 PM by Nick Gammon
Australia Forum Administrator #1
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.
#2
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
#3
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.
Australia Forum Administrator #4

 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.
#5
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.
Australia Forum Administrator #6
A straight compare like this will not work for a list:


if "@nokill" ~= "%2"


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.
#7
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?
Australia Forum Administrator #8
This might be relevant:

http://www.gammon.com.au/forum/?id=9311