How to get a trigger to fire only once per room

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

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

Post 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.

amateras
Posts: 13
Joined: Mon Dec 24, 2012 12:39 am

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

Post by amateras »

Thank you demonnic - that works like a charm!

Atreus
Posts: 1
Joined: Tue Aug 27, 2019 8:43 am

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

Post 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.

Post Reply