[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Newbie Scripting - Invoking.
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Newbie Scripting - Invoking.

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


Posted by RedX   (1 post)  [Biography] 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 &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?
[Go to top] top

Posted by Shadowfyr   USA  (1,783 posts)  [Biography] 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 &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.
[Go to top] 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.


4,222 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]