Register forum user name Search FAQ

Gammon Forum

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 ➜ Basic question on an "if" script

Basic question on an "if" script

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Rena   (9 posts)  Bio
Date Tue 10 Feb 2009 05:59 PM (UTC)
Message
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.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 10 Feb 2009 07:04 PM (UTC)

Amended on Tue 10 Feb 2009 07:05 PM (UTC) by Nick Gammon

Message
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+)



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Rena   (9 posts)  Bio
Date Reply #2 on Tue 10 Feb 2009 08:24 PM (UTC)
Message
Oh, right, that makes sense. I forgot that regular expressions work totally different with wildcards.

Thanks!
Top

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.


15,199 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.