Page 2 of 2

Re: How to get a trigger to fire only once per room

Posted: Fri Mar 01, 2013 7:26 am
by demonnic
In the trigger that says there are corpses, just set a flag. iNeedToLootStuff = true.

Then in your prompt trigger you can simply put
Code: [show] | [select all] lua
if iNeedToLootStuff then
  iNeedToLootStuff = false
  send("ga")
end
Assuming you have a prompt trigger. If you don't, the pattern I would use to match the prompt I see in the screenshot above would be: ^(\d+)hp (\d+)m (\d+)mv>$

Assuming you wanted to store off the values. If you didn't want to, then you can remove all of the parentheses.

Re: How to get a trigger to fire only once per room

Posted: Fri Mar 01, 2013 2:28 pm
by amateras
Thank you demonnic - that works like a charm!

Re: How to get a trigger to fire only once per room

Posted: Wed Aug 28, 2019 10:39 am
by Atreus
But doesn't that only work once? After that, the value of the variable is "false", and nothing happens when you enter another room, right?

I solved a similar issue by using a tempTimer, like this:

I have set a global variable "skin" with a default (integer) value of 0 to make sure I can always skin a corpse when I login. My trigger has the following small code snippet:

Code: Select all

if skin == 0 then
  skin = 1
  send ("get all heart to sack")
  tempTimer (2, [[skin = 0]])
end
So, when I skin a corpse, the trigger fires on the first line that matches, it gets all hearts from the ground and puts them in a sack and, at the same time, the variable value changes to 1 preventing the trigger from firing on subsequent matching lines until, after 2 seconds, the variable value is set back to 0 so the next time I skin a corpse, the trigger will fire again.