Trigger with a newline prompt

Posted by Helio on Mon 29 Jul 2002 02:51 PM — 5 posts, 18,870 views.

#0
Hi, I was wondering if it was possible to call from a prompt when a trigger shoots.
Ie:

Without warning Blah stabs you from behind!
<HP:200 EP:200>

So when i see that i want to send to world.
$:has been backstabbed by Blah at HP:200 EP:200 !!

Is that possible?
USA #1
With scripting yes.. I have had to do something similar on my mud for a few things. What you need is two triggers and a small script like:

Trigger 1->
Match:^Without warning (.*) stabs you from behind!$
Regular Expression: Checked
Label: StabCap
Script: StabCap

Trigger 2->
Match:^<(HP:* EP:*)>$
Regular Expression: Checked
Label: StabOff
Script: StabCap

Script->

sub StabCap (name, output, wildcards)
  if name = "StabCap" then
    world.setvariable "StabName", wildcards(1)
    world.enabletrigger "StabOff", TRUE
  else
    world.send "$:has been backstabbed by " & world.getvariable ("StabName") & " at " & wildcards(1)
    world.enabletrigger "StabOff", FALSE
  end if
end sub


Assuming that I didn't goof someplace... This should work. ;)
#2
sorry to tell you , but ur trigger doesnt work... can someone pls help me?!
Thanks
USA #3
>Match:^<(HP:* EP:*)>$

Oops.. I did say that I may have goofed. lol The above should have been:
Match:^<(HP:.* EP:.*)>$

As . means any character and * means one of more of them. What I had was :* which is one or more :, so it could only have matched on <(HP: EP:)>, <(HP::: EP::)>, <(HP: EP:::)>, etc.

I really hate regular expressions, but when you somehow manage to get them right they are very accurate. ;)

Oh.. And it help if you meantion 'which' trigger and how it failed, though in this case I assume you figured both had failed and didn't check your variables list to see if the first one actually set StabName. Not a big deal. I find that one easy way to see if a trigger does fire is to set each new trigger to change the text to a custom color (and that custom color to something you don't normally see on a mud like hot pink), then if one fires, but the other fails you can tell immediately where the problem is. ;) Just remember to set the trigger back to no-change when it is working or you end up with a lot of hot pink text. lol
Amended on Wed 31 Jul 2002 05:47 PM by Shadowfyr
Canada #4
You need to "escape" almost all the punctuation, by proceeding it with a \ character:

^\<(HP\:.* EP\:.*)\>$