Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, 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.
Entire forum
➜ MUSHclient
➜ Lua
➜ Newbie Scripting - Invoking.
Newbie Scripting - Invoking.
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| RedX
(1 post) Bio
|
Date
| Sun 06 Jan 2008 11:44 AM (UTC) Amended on Sun 06 Jan 2008 11:56 AM (UTC) by RedX
|
Message
| I have got a trigger for when i appraise a mob to set whatever i am appraising to my target. I then have an alias to steal all of their gold, which is not automatically fired. I am looking to write a script to automate the stealing if the mob has over 50 on them.
<triggers>
<trigger
custom_colour="17"
enabled="y"
expand_variables="y"
lines_to_match="2"
keep_evaluating="y"
match="Judging from the bulge in (her|his) money pouch, (she|he) must be carrying close to * gold pieces."
send_to="12"
sequence="10"
other_text_colour="darkmagenta"
>
<send>if %3 > 50 then
Send( "stealgold" )
end -- if</send>
</trigger>
</triggers>
I don't know how far wrong i am, i was basing by theory. This trigger doesn't seem to do anything, it doesn't even change the colour of the text, can you tell me where i am going wrong? | Top |
|
Posted by
| Shadowfyr
USA (1,788 posts) Bio
|
Date
| Reply #1 on Sun 06 Jan 2008 06:53 PM (UTC) |
Message
| (her|his) type matches only work in regular expressions, and * in regexp means, "multiple copies of the prior character", not "match anything". By itself, " *" would mean, "one or more spaces", in regexp. Oh, and . means "any character", so you have to make you "." into "\.", which means, "Look for a literal '.' here." Try this:
<triggers>
<trigger
custom_colour="17"
enabled="y"
expand_variables="y"
lines_to_match="2"
keep_evaluating="y"
regexp="y"
match="^Judging from the bulge in (her|his) money pouch, (she|he) must be carrying close to .* gold pieces\.$"
send_to="12"
sequence="10"
other_text_colour="darkmagenta"
>
<send>if %3 > 50 then
Send( "stealgold" )
end -- if</send>
</trigger>
</triggers>
You did pretty well. The only issue is that special stuff like either or matching requires regular expressions. The only type of match allowed in "normal" triggers is the use of the "*" character. Oh, note: ^ and $ are special characters in regexp that say, ^ - this is the very start of a line, do not match *unless* the next character is the first one to appear on the line, and $ - This is the end of the line, if more text follows this, don't match. You might need to remove one or both, depending on if the sentence appears by itself or not, and if you have a mud that likes to drop new information on the same line as a prompt. For example, using ^, this wouldn't match:
Jan 6, 2008> Judging from the bulge ...
Because it starts with a prompt, showing the date. Same is true if you have a mud like mine, which "insists" on adding a space, even if you set the prompt to be empty. Simplest solution if that is happening it to remove the ^ from the trigger, but then you have to worry about some clown posting a message like, "Jerk says: OMFG! Judging from the bulge in his money pouch, he must be carrying close to 5000 gold pieces.", and triggering your match anyway. :p Its possible, to a point, to bullet proof it, but a lot easier if you *know* the line will never appear on a prompt in the first place. | 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.
13,205 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top