Converting triggers and what they mean

Posted by Hathcock on Wed 03 Dec 2003 10:27 PM — 28 posts, 101,816 views.

#0
I'm very thankful for all the help I've received, especially from Shadowfyr. I've figured out how to convert most of the triggers using the examples given, but there are a few that have me completly lost again....and I was wondering why they were written this way...for what reason?

This first one is because of a problem I guess in the game were a random letter or two is replaced with an astric within the word. I tried a couple ways of converting using the regular expressions table in the help files, but i kept saying I had errors when I tried to paste it.

#TRIGGER {{A|*}{*| }{*|p}{r|*}{*|i}{c|*}{k|*}{l|*}{y|*}{*| }{s|*}{t|*}{i|*}{n|*}{g|*}} {eb;#var frenzy 1;#t- Attacks;#cw red}

This next one really has me confused, I don't even know what it is used for, but it seems important

#TRIGGER {^You may eat another plant.$} {bal;#if {@stupid=1} {herb= Goldenseal (Stupidity)} ;#if {@goldenseal=1} {herb= Goldenseal};#if {@bloodroot=1} {herb= Bloodroot};#if {@kelp=1} {herb= Kelp};#if {@lobelia=1} {herb= Lobelia} ;#if {@ginseng=1} {herb= Ginseng};#if {@ash=1} {herb= Ash};#if {@bellwort=1} {herb= Bellwort};#cw 13}

This last one looks like the above, to me atleast, just alot shorter....what is up with all the herbbalance = 0 stuff?

#TRIGGER {You eat a bloodroot leaf.$The plant has no effect.} {#var bloodroot 1;herb= Bloodroot}


Anyone able to help I'd be appreciative as always, thanks
USA #1
It's rather difficult to tell what these are meant to do taken out of context, but here are a few thoughts...

The first one seems to be matching on "a prickly sting" - now why there are all those other things in there, I don't know. It depends completely on the output of your MUD, so it's impossible to tell why it's there without seeing sample output. In any case it seems to be sending the command "eb" and setting variable frenzy to 1, and then turning off trigger group attacks? (?) And then doing #cw red, whatever that means.

It's hard to help you with the second one if you're not sure what it even does :)
It seems that it's just setting up the variable "herb" depending on a whole bunch of conditions.

I don't really know enough about zMUD syntax to translate all this meaningfully. Again, it's also very difficult to tell what it's supposed to do without any context... it's like trying to translate something from a foreign language to English, but without speaking the foreign language nor knowing what the text is supposed to say...
#2
for the first one, here is an example of what I see...the missing letter is usually different each time.

A prickly st*n*ing over*helms your body, fading away into numbness.

What is a variable used for? You mentioned herb variable?
#3
I noticed also that sometimes when I paste a triiger, that it doesn't set it as a regular expression like most of the other are....should they all be regular expressions or do I just leave it be?
#4
if I have it set up to keep attacking every time I regain balance, is there a way I have have a trigger that goes off once I reach a certain amount of heaklth, to mend myself?
this is what the config promt thing looks like

H:546 M:860 B:100% [eb]
USA #5
Ok. First trigger.. You didn't read one of my previous explainations too well. * is not an asterix in either type of trigger. You can't use it at all in a normal trigger and in a regular expression it means "more than one of the prior character or group". Since | is an "OR", there is no character or group for it to look for more than one of. I have no idea why this works in zMud, except that zMud often doesn't correctly follow its own standards sometimes, let alone anyone elses. However, at a guess, I suspect that the use of {} in zMud is a way to include "|" commands without using regular expressions. The correct form in mushclient would be:

(A|\*)(\*| )(\*|p)(r|\*)(\*|i)(c|\*)(k|\*)(l|\*){y|\*)(\*| )(s|\*)(t|\*)(i|\*)(n|\*)(g|\*)

and set it as a regular expression. In this case '\' tells the regular expression parser to treat the next character as a 'real' one and not a command. So \* would be a literal * and not a request to look for more that one of something.

The rest is like this:

send "eb"
frenzy = 1
enablegroup "Attacks", 0

Note we completely ignore the #VAR command. In zMud this is the same as saying DIM in VB. VBSCript will automatically create a variable as soon as used, so this is redundant. Instead we simply set frenzy = 1 and VBScript handles the rest.

It also uses a ColorWord command. Seeing how it is used here, I now suspect this is the equivalent of setting a color trigger in this case. Which is to say that the trigger turns the line with the "A prickly sting" on it red. The other triggers I helped you with send an error, then set the color of "that" line to red, or so I think... If you use the "Change colour and style" in the trigger in 'Edit' or 'Add' to use red (Either the custom color that is red or using "Other.." and selecting red for the foreground). This will color the words red, as I assume the original was supposed to.

Now as for the second one.. I just love scripting that crams every bloody thing on one line, so lets shift stuff around a bit so it makes more sense first:

TRIGGER {^You may eat another plant.$} {
  bal;
  #if {@stupid=1} {herb= Goldenseal (Stupidity)} ;
  #if {@goldenseal=1} {herb= Goldenseal};
  #if {@bloodroot=1} {herb= Bloodroot};
  #if {@kelp=1} {herb= Kelp};
  #if {@lobelia=1} {herb= Lobelia} ;
  #if {@ginseng=1} {herb= Ginseng};
  #if {@ash=1} {herb= Ash};
  #if {@bellwort=1} {herb= Bellwort};
  #cw 13
}

That's better. ;) Now we can see what it really does. And can make a trigger that works as intended:

<trigger
  match="^You may eat another plant.$"
  regexp="y"
  enabled="y"
  send_to="12"
  custom_colour="17"
  other_text_colour="fuchsia"
  other_back_colour="black">
  <send>send &quot;bal&quot;
if stupid = 1 then
  herb = "Goldenseal (Stupidity)"
end if
if goldenseal = 1 then
  herb= "Goldenseal"
end if
if bloodroot = 1
  herb = "Bloodroot"
end if
if kelp = 1 then
  herb = "Kelp"
end if
if lobelia = 1 then
  herb= Lobelia
end if
if ginseng = 1 then
  herb= Ginseng
end if
if ash = 1 then
  herb= Ash
end if
if bellwort = 1 then
  herb= Bellwort
end if</send>
</trigger>

A few explainations. I could have used custom_colour="13" and for most people it would be the same. However, since custom color can be changed, it is safer to use the equivalent 'real' color to the original ANSI. In this case the 'real' color that corresponds to bright-magenta is Fuchsia. By using custom_color="17", which is the same as setting it to "Other..." in the trigger editing dialog, you can specify any color you want, even of the set of 16 custom colors are completely changed from the normal ANSI colors. On my client only 2-3 of those colors are still the originals and color 13 would have ended up Orange.

The third one also uses #VAR. Again, just ignore this and make it bloodroot = 1. Note also that we place "" around strings. zMud uses @ to refer to the 'contents' of a variable and apparently leaving that off means it assumes that you are assigning a string to a variable. This isn't exactly consistant with any other language I know of. lol

Also, with the third trigger you will see that they use $ in it. This means that what it is literally looking for is:

You eat a bloodroot leaf.
The plant has no effect.

Mushclient "cannot" match multiple lines, so this gets complicated. You need two triggers. The first on needs to set a variable to tell the second trigger that it was a bloodroot that you used. If there are more than one of these triggers that match two lines, then things are bound to become a mess. However, the solution would be like:

<trigger
  match="You eat a bloodroot leaf."
  enabled="y"
  sent_to="12">
  <send>herbeaten = "bloodroot"</send>
</trigger>

<trigger
  match="You eat a goldenseal flower."
  enabled="y"
  sent_to="12">
  <send>herbeaten = "goldenseal"</send>
</trigger>

<trigger
  match="The plant has no effect."
  enabled="y"
  send_to="12">
  <send>select case herbeaten
  case "bloodroot"
    bloodroot = 1
    herb = "bloodroot"
  case "goldenseal"
    goldenseal = 1
    herb = "goldenseal"
end select</send>

The goldenseal trigger and "case" are examples and may differ for the triggers you are converting. However, they should give you an idea what I mean. Each trigger for the first line has to 'tell' the trigger for the second line what you just ate and the "case" sections in there handle setting the correct variables for each herb type. Simple. ;)
USA #6
I think, actually, that the * in the expression is actually used as the * wildcard, much like it would be in DOS or explorer searching or something.

To emulate that using "real" (quote, not emphasis, Shadowfyr :P) regular expressions, you'd want to do ".*", where the . is what's called a "metacharacter" which means, basically, "any character".

I think that even if you manage to do dumb conversions like this (I don't mean dumb as in stupid, but as in blind/mechanical) it's quite possible that your system will end up still not working. Much better would be to know what your system does, and then emulate that. It seems that the idea is simple enough, and should be feasible in just an hour's or so work. But if you (or someone else, for that matter) make a mistake during this dumb conversion you can easily mess up your system and introduce subtle errors without even knowing it.

I've never heard of purchasing a trigger package... what kind of deal is that? People actually make money selling triggers? Pfft...
USA #7
Another note: you can't just copy/paste zMUD triggers into MUSHclient because the two applications use different formats. It's a little like copy/pasting C code into a Java compiler.
#8
How do I write this as a trigger with wildcards before and after it...

gathering momentum as {he|she} bears


Also, how do I set up Autoheal?
this is what my prompt looks like

H:546 M:860 B:100% [eb]
USA #9
I believe writing:
gathering momentum as * bears
would be sufficient. Only problem is that the wildcard could match on more than just he/she, but I'm not sure how much of a problem that is.

I think the right way using regular expressions would be:
gathering momentum as (he|she) bears

I don't think you need left and right parts, but if you do, those would be something like:
$.*gathering momentum as (he|she) bears.*^

I might have mixed up $ and ^... I take them to mean respectively "beginning of line" and "end of line" but it might be the other way around.

Matching prompts is a little tricky due to some newline problems; you can do a search on the forum for prompt and newline and see what you come up with. :) Basically the problem is that since newlines don't come after the prompt, you don't know you've received the prompt until the line finishes - either when you receive something new or when you type something yourself.
Canada #10
Man, one of you people who play that mud has got to come up with a plugin you can just share amongst yourselves. Heh... ;)

Do a search of the mushclient forums on the word "goldenseal" and about 6 or 7 threads show up.

That whole thing with the astericks in a phrase (Done to prevent triggering, by the mud admins), there's been a couple of threads on that too, although, unfortunately, I can't think of what keywords might bring up the threads in a search.
USA #11
Yes Ksilyan, you got the ^ and $ backwards. As for the "*" issue. Like Magnum said, this is intended to be an anti-trigger feature (not that it works), but I am 99.9% sure that using {} in zMud, instead of () means 'treat these as literal strings'. A wildcard in those places would be ineffective, since it would match on literally any line at all. In other words, using a wildcard in there, instead of a literal you net you a trigger equivalent to "***************" Any line 15 characters or more in length would cause it to trigger. This make is quite obvious that they intended the * in that trigger to be literals, not wildcards.

As for you autoheal:

<trigger
  match="H/:/d+ M/:/d+ B/:/d+/% /[eb/]"
  enabled="y"
  regexp="y"
  send_to="12">
  <send>if %1 > LastHP then
  LastHP = %1
else
  if %1 / LastHP <= 0.5 then ' Check percentage of last highest HP.
    send "heal" 'Send command hear.
  end if
end if</send>
</trigger>

Your prompt doesn't provide the original maximum and you don't mention what command you use to heal, so the above is a best guess. You will need to replace "heal" with whatever you actually use to heal yourself. Also, the 0.5 means '50%', so if you want to heal at a different point, you need to also change that. One change you may want to make is to replace the 0.5 with getvariable("HealPercent"), then add an alias like:

<alias
  match="setheal *"
  enabled="y"
  send_to="12">
  <send>setvariable "HealPercent", %1
note "You will now auto-heal at: " & %1 * 100 & "%."
save ""</send>
<alias>

This will set a variable that is internal to the client and thus is saved 'in' the world file. Everything I have used so far are script variables, whose values vanish as soon as the script closes. A world variable, if the world is saved properly, will persist from one to session to the next. The 'save ""' line will save the entire worlds settings, including the variable you just changed.

In plugins, this is handled a bit differently. By setting the plugin's save_state setting to "y", Mushclient automatically updates a special file that stores variables, every time you change one. This works like an automatic version of 'save ""' for plugins, though the values are not stored in the plugin itself. The reason being that state files are files named with WorldID-PluginID.XML. This allows each character(world file) to use the same plugins, but completely different settings. Had you provided a complete list of things you needed, and it didn't immediately send me screaming away from the computer, I would have likely created such a plugin instead. However, had you dropped the whole mess in our laps I would probably not have touched it with a ten foot pole. I hate zMud's script engine with a passion. ;) lol
USA #12
I'm not sure at all about what you say concerning the first one, Shadowfyr, the one with the prickly sting, because he posted that the output is something like:

Quote:

for the first one, here is an example of what I see...the missing letter is usually different each time.

A prickly st*n*ing over*helms your body, fading away into numbness.


Where the stars represent changeable letters.

So, "this makes it quite obvious" (echo... :P) that what the trigger is doing is allowing every single letter to either be what it should be, or be a star. Assuming, of course, that that output is actual output, and that the stars represent variable letters.
Canada #13
See this thread for how to build a trigger that gets around anti-trigger lines that uses astericks in random places:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=2544
Australia Forum Administrator #14
You might be able to match on the optional asterisks in a more readable way:


A [p*][r*][i*][c*][k*][l*][y*] .*


Each of the things in square brackets is an alternative letter to match on, so it is a bit easier to read what the word is.
#15
When pasting the autoheal trigger, I get this error
Line 10: Element name must start with letter or underscore, but starts with "=" (problem in this file)

Thanks for the help, I'm sorry it made you run from your computer Shadowfyr. If I was able to find a system for this realm I would have bought it, but I haven't found one, so I'm forced to ask for everyone's help, since I'm practically computer illiterate.
USA #16
Hmm.. Creating it by hand and doing a copy I get:

<triggers>
  <trigger
   enabled="y"
   match="H/:/d+ M/:/d+ B/:/d+/% /[eb/]"
   regexp="y"
   send_to="12"
  >
  <send>if %1 &gt; LastHP then
  LastHP = %1
else
  if %1 / LastHP &lt;= 0.5 then ' Check percentage of last highest HP.
    send &quot;heal&quot; 'Send command hear.
  end if
end if</send>
  </trigger>
</triggers>

The problem if you compare them in that I used < instead of &lt;, so the parser thought that it was the start of a new XML tag. Ooops!

As for Nick's idea.. Are you sure that would work Nick. It is a better option, but it still requires a regular expression and that means that * will probably still need to be made into \*. I could be wrong though.
Amended on Thu 04 Dec 2003 10:30 PM by Shadowfyr
#17
If you are talking about the Prickly Stinging thing...it appears as I showed it....random letters in the first few words are replaced by astricts by the realm
USA #18
Actually Shadowfyr, I believe that that IS a regex... the [] means "character class", so when you have a * inside that it doesn't have the same meaning. For example, [azjb*] means match on any one of a, z, j, b, or *.

The poor word "asterisk" has had enough mutilation in this thread... it's spelled asterisk. That poor word gets so banged up all over the Internet... :P
USA #19
The asterisk thing (prickey, etc) has shown up on another thread, instead of reinventing the wheel, search the forum for it...
#20
The autoheal trigger still doesn't work...I don't get any response from it, I tried to mess with it and make a wildcard after the H: but that just started an endless loop of drinking health.
USA #21
Grr.. Stupid me.. I forgot to tell it which parts are returned... Try:

^H\:(\d+) M\:(\d+) B\:(\d+)\% \[eb\]

The () is used in regular expressions to both create a sub string for some special situations, but also to tell the regular expression parser which bits should be returned as a value. The above version should give you health as %1, magic as %2 and whatever B: is as %3. So it should work right. Oddly it should have matched anyway, but... Gah!! Just realized I had all the wrong \ characters in there... :p I keep confusing the damn things. lol Also, if the [eb] part changes in any way as you play, you may want to replace it with \[.*\] instead. ;)

Note: I also added the ^ character above. This is to prevent someone from sending you a tell or something containing text like>

Fred tells you: H:1 M:200 B:50% [eb] - Scary! I almost died..

This happens every once in a while on the mud I play and unless you use ^ to 'lock' your trigger to only things on a newline it can wreck havoc with triggers like this one.
#22
wow, that worked great....but one problem, and this is my fault....I can only drink from the health vial once every few secinds...so when I go below the .5 it sends a loop that makes me drink my entire vial in a large spam of the trigger. Is there something I can add to stop it from looping itself like that so fast? Or atleast until I'm able to drink a second health vial?
USA #23
Hmm.. You could change it to something like:

if %1 &gt; LastHP then
  LastHP = %1
else
  if %1 / LastHP &lt;= 0.5 then ' Check percentage of last highest HP.
    if abs(datediff("s",ldrinktm,now)) > 2 then
      send &quot;heal&quot; 'Send command hear.
      ldrinktm = now
    end if
  end if
end if

This would mean that the first drink you take will set ldrinktm to the current time and day. The next prompt would then get as far as the 'if abs(datediff("s",ldrinktm,now)) > 2 then' line and skip over the command if at least 2 seconds haven't passed. The reason I use abs() is because I can never bloody remember which order the dang dates being compared need to be in. lol Just increase the '2' to how ever many second you need, not to mention the other changes you probably made to use it originally of course. ;)
#24
I'm really sorry to keep at this, but the autoheal still isn't working, for some reason it heals every time the config prompt comes up(H:580 M:670....) with a 2 second delay of course...is there a way to just do something like
trigger : H:(.*?)
send: if %1 < 2880
send "Heal"

anything simple like that?
USA #25
Hmm. I don't get why it is doing that... unless I got some code wrong. It should only heal if it drops under 50% of your maximum, not every time. The only reason it would not is if you used something that boosted you HP to more than double and that later dropped back to less than half of that max....

Also I am confused... Your previous statement was that you could only drink a potion to heal yourself every X seconds. This is an improved version of that, which will act in any case where your health is below the last 'normal' level, but it still acts on a delay. However, once you are completely healed it shouldn't continue to heal you:

<triggers>
  <trigger
   enabled="y"
   match="^H\:(\d+) M\:(\d+) B\:(\d+)\% [.*]"
   regexp="y"
   send_to="12"
  >
  <send>if %1 &gt; LastHP then
  LastHP = %1
else
  if %1 &lt; LastHP then
    if abs(datediff(&quot;s&quot;,ldrinktm,now)) &gt; 2 then
      send &quot;heal&quot;
      ldrinktm = now
    end if
  end if
end if</send>
  </trigger>
</triggers>


Yes, you can do what you asked though and simplify it to:

<triggers>
  <trigger
   enabled="y"
   match="^H\:(\d+) M\:(\d+) B\:(\d+)\% [.*]"
   regexp="y"
   send_to="12"
  >
  <send>if %1 &gt;= LastHP then
  LastHP = %1
else
  send &quot;heal&quot;
end if</send>
  </trigger>
</triggers>

However, if you do that, then it is right back to healing you on 'every' single status prompt, even if you are currently unable to use a potion again, which is what you prevously said you wanted to avoid. It would be a heck of a lot easier if the prompt included something like H:500/2000, where you can see the maximum you are testing against, but...

You could however make an alias that set LastHP, so you can tell it what number to look for, however doing so means you need to remember to tell it what you max HP is every time you start, which the code above was supposed to avoid.
Amended on Sat 06 Dec 2003 12:46 AM by Shadowfyr
Australia Forum Administrator #26
Quote:

As for Nick's idea.. Are you sure that would work Nick. It is a better option, but it still requires a regular expression and that means that * will probably still need to be made into \*. I could be wrong though.


Yep, I tried it, otherwise I would have thought the same thing. The * for multiples applies to a character or wildcard, but within the square brackets it is taken literally. Saves a few backslashes.
Canada #27
I'd be curious to know what game this is for because it looks an awful lot like sylvanus at a quick glance...