Timed Trigger

Posted by Talmord on Thu 23 Aug 2007 10:57 PM — 7 posts, 26,583 views.

#0
<module(..., package.seeall);

<triggers>
<trigger
enabled="y"
keep_evaluating="n"
name="Aeon"
omit_from_output="n"
regexp="y"
sequence="100"
script="Curing"
match="="^.* stands a tarot on his open palm\, and blows it lightly at you\. .*$"
</trigger>

require "wait"
wait.make (function ()

world.Send (world.Setoption ("enable_triggers",0)
wait.time (0)
world.Send (inject demulcent\nworld.Setoption("enable_triggers",1),"1")
world.Note ("Attempting to cure Aeon. Standby)

end)
</send>
</trigger>
</triggers>

Something's wrong with the syntax. I keep getting the error message A letter or underscore should precede the attribute value instead of (. This trigger is supposed to switch off all triggers, cure, then switch triggers back on again.
Australia Forum Administrator #1
I would drop the first line (<module(..., package.seeall);) - I don't see what it is doing there.
Netherlands #2
You never closed the first <trigger> tag nor do you open the <send> tag. E.g.:

<triggers>
<trigger
enabled="y"
keep_evaluating="n"
name="Aeon"
omit_from_output="n"
regexp="y"
sequence="100"
script="Curing"
match="="^.* stands a tarot on his open palm\, and blows it lightly at you\. .*$">
<send>

require "wait"
wait.make (function ()

world.Send (world.Setoption ("enable_triggers",0) )
wait.time (0)
world.Send ("inject demulcent")
world.Send (world.Setoption("enable_triggers", 1) )
world.Note ("Attempting to cure Aeon. Standby)

end)
</send>
</trigger>
</triggers>


I can't see whether your Lua is proper since I'm not all that good at Lua, but one error that stands out are your world.SetOption lines. I've fixed those up too, although I'm not sure if they do what you want.
USA #3
world.Note ("Attempting to cure Aeon. Standby)


might want to be

world.Note ("Attempting to cure Aeon. Standby")


(note closing quote)

Also, you have a trailing "end)" in your code, but I'm not sure what it's for.
Australia Forum Administrator #4
That part is OK:


wait.make (function ()

-- function code here

end)

USA #5
Oops -- didn't see the function opening. My bad. :-)
Australia Forum Administrator #6
Quote:

world.Send (world.Setoption("enable_triggers", 1) )


It is SetOption, not Setoption, you have to get the capitalization correct:

http://www.gammon.com.au/scripts/doc.php?function=SetOption

Also, why do a world.Send of the result? Assuming the SetOption worked, you would simply be sending "0" to the world.