Basic question on an "if" script

Posted by Rena on Tue 10 Feb 2009 05:59 PM — 3 posts, 15,507 views.

#0
So I was working through the MUSHclient tutorial (http://www.gammon.com.au/forum/?id=6030) and copied this text from it:

if %1 < 100 then
ColourNote ("white", "red", "Warning! - health is low")
end -- if

It's meant to trigger on your health/mana line.

I changed the 100 to 4000 and had it trigger on this: ^Endurance: */*

But, any time the text of that form shows up, whether the number is above or below 4000, it gives me an error:

[string "Trigger: "]:1: unexpected symbol near '<'

But I'm just doing what the tutorial said! What's going wrong? Lua is what I have set as my scripting language.
Australia Forum Administrator #1
You are doing what the tutorial said, but you have changed the trigger. ;)

It helps when posting a problem like this to post the whole trigger, so I can see exactly what you have done:

http://mushclient.com/copying

Also post an example of MUD output, so it is possible to test the trigger.

Your trigger text looks a bit like a regular expression because it starts with ^, however the rest is not correct if you have checked "regular expression".

If you have indeed checked the regular expression box, then you need to catch digits, and make them a "capture" otherwise %1 will be empty, which would account for the error message. For instance:


^Endurance: (\d+)/(\d+)


Amended on Tue 10 Feb 2009 07:05 PM by Nick Gammon
#2
Oh, right, that makes sense. I forgot that regular expressions work totally different with wildcards.

Thanks!