Newbie Scripting - Invoking.

Posted by RedX on Sun 06 Jan 2008 11:44 AM — 2 posts, 16,722 views.

#0
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 &gt; 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?
Amended on Sun 06 Jan 2008 11:56 AM by RedX
USA #1
(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 &gt; 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.