Gagging and Text Replacement

Posted by Flelm on Sun 21 Aug 2005 09:24 AM — 6 posts, 28,512 views.

#0
I'm having problems with the "omit from output" part of a trigger. Here's the relevant code.

<trigger
enabled="y"
keep_evaluating="y"
match="^ ([A-Za-z]+) was in the sign of( the)? ([A-Za-z ]+)\.$"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>Nativity ("%1", "%3")</send>
</trigger>

function Nativity (a, b)

Note ("TESTING")

end

If I check omit_from_output, neither the line nor the Note shows up, even though the function is being called. How do I replace the triggered line with my line?

SAMPLE TRIGGER LINE:
Sun was in the sign of Dragon.


Thanks in advance
Russia #1
If you set a trigger that sends to script to omit from output then the send text will be omitted also. The solution is to put your script into a function callable by a trigger and do it through the script file, instead of directly inside the trigger. Or if you absolutely don't want to use a script file for some reason you could probably make two triggers to match on the same line, one to execute the script (keep evaluating - yes, sequence - 99) and another to omit from output (sequence - 100). That way the first trigger will match and perform whatever actions you need, and the second will omit the line.
Sweden #2
Uhmmm...that might be working with Lua but how does one do it in PerlScript ? The only way I have been able to get any output from a trigger that omits output from output window is to set up a one-shot timer, the suggested call a sub in the script file just simply doesn't work.
What I did test is a sub in the scriptfile that looks like:

sub outputTest() {
  $world->note("Modified output: You are hungry.");
}

and a trigger that that looks like:
Trigger text: "You are hungry."
Action contents: "outputTest();"
Send to: Script

What am I doing wrong here ?

// Fredrik
Amended on Sun 21 Aug 2005 01:27 PM by Ekerim
Russia #3
You are still sending to script which won't work. You need to put the function name in the trigger's Script box (lower right corner of the trigger edit dialogue), and make sure that this function accepts exactly 3 arguments. The trigger will call this function passing its' own (the trigger's) name, whatever is in its Send box, and a list of captured wildcards in the arguments. So your "outputTest" sub should look like:

sub outputTest(name, output, wildcs) {}

or whichever way you declare accepted arguments in Perl.
Russia #4
Ooops, missed the "doesn't work" part. Why wouldn't it work for Perl? Does it say anything at all?

And have you tried using two triggers for the same line?
Sweden #5
Thanks for the answer...

I acctually missed that Script field for the trigger, I will test that next. I have it working ok now with a 0.1 sec delay coz of the DoAfterSpecial i use to get it to work. It would be preferable to not have any delay since I use it to highlight enemy player spellcasters casting offensive spells at me :)

Yes, I did test two triggers, one at sequence 50 that would write write modified text and one at 100 that would gag. That didn't work.

// Fredrik

[Added]I have it working using the Script field now. Thanks alot!