If/Then/Else trigger troubles

Posted by RalenthNaelore on Tue 31 Jul 2018 06:10 PM — 5 posts, 21,190 views.

#0
So I'm getting this error

"Compile error
World: The Lost Fates
Immediate execution
[string "Trigger: "]:1: '=' expected near 'A'"

From this:

If %1 == "a skeletal rat" Then send("skin corpse")
Elseif send("search corpse")
End

And I do have my send to set to be Script. I'm not sure what exactly I've done wrong here. I've made some progress I think, as it's now picking up the first word, rather than the last. However, I can't seem to figure out what I'm doing wrong despite reading extensively over the last couple of days on LUA and here in the forums.
Australia Forum Administrator #1
Lua is case-sensitive. It is "if" not "If" and so on. Like this:


if "%1" == "a skeletal rat" then 
   Send("skin corpse")
else 
  Send("search corpse")
end


(Also it is "Send" not "send"). Check the documenatation for the capitalization.

Also see:

Template:faq=32
Please read the MUSHclient FAQ - point 32.
#2
Ah, super! I don't know how I didn't run across those files before. That's the sort of thing that I was looking for and couldn't find! And thanks for correcting my trigger - I had originally had them lower case and then switched them because I remembered seeing that they were case sensitive but I didn't know which way was the correct one and I couldn't get them working.
#3
So I've been refining this a little bit, and I've managed to tidy up all the problems with compiling, but now the trigger isn't firing at all, and I'm not exactly sure what I've done wrong.

DoAfter (3, "if '%2' == 'skeletal rat' then Send('skin corpse') else Send('search corpse') end")

Shouldn't this fire off my comparison after three seconds? (To allow for roundtime to expire if I hit the last blow)
Australia Forum Administrator #4
You want DoAfterSpecial (so you can send script commands). But would this be simpler?


if '%2' == 'skeletal rat' then
  DoAfter (3, 'skin corpse')
else
  DoAfter (3, 'search corpse')
end  -- if


That moves the if tests to the trigger which makes it simpler, and lets you do a simple DoAfter (which sends direct to the MUD).

Template:function=DoAfterSpecial
DoAfterSpecial

The documentation for the DoAfterSpecial script function is available online. It is also in the MUSHclient help file.