Hello all. Stumbled upon a small (I hope) problem. Here is it. Imagine you have a line:
First thing. Second thing.
The trigger firing on Second thing is not enabled all the time and must be turned on only if the First thing precedes it. So, after we've got the First thing, the second trigger enables, does his work and turns itself off, so it won't fire without getting the First thing first. That's the code:
<triggers>
<trigger
enabled="y"
keep_evaluating="y"
match="First thing"
regexp="y"
send_to="12"
sequence="100"
>
<send>
world.EnableTriggerGroup('second', True)
world.Note('1st trigger fired, 2nd trigger on')
</send>
</trigger>
<trigger
group="BASHER"
match="Second thing"
regexp="y"
send_to="12"
sequence="100"
>
<send>
world.EnableTriggerGroup('second', False)
world.Note('2nd trigger fired and turned off.')
</send>
</trigger>
</triggers>
Everything's working just fine:
You say, "First thing. Second thing."
1st trigger fired, 2nd trigger on
2nd trigger fired and turned off.
You say, "Second thing."
But as I need to do some complex work inside these triggers, I would prefer having the triggers call functions from the script file. The code changes to:
<triggers>
<trigger
enabled="y"
keep_evaluating="y"
match="First thing"
name="first"
regexp="y"
script="first"
sequence="100"
>
</trigger>
<trigger
group="second"
match="Second thing"
name="second"
regexp="y"
script="second"
sequence="100"
>
</trigger>
</triggers>
With the corresponding functions looking exactly like above:
def first(name, line, wildcards):
world.EnableTriggerGroup('second', True)
world.Note('1st trigger fired, 2nd trigger on')
def second(name, line, wildcards):
world.EnableTriggerGroup('second', False)
world.Note('2nd trigger fired and turned off.')
Unfortunately, this breaks everything. Now it works like:
You say, "First thing. Second thing."
1st trigger fired, 2nd trigger on
As you can see, the second trigger fails to fire.
Sorry for such a long depiction of a problem, thought it might help to include everything. Would be grateful for any thoughts. |