Timer problem

Posted by Shinth on Mon 06 Aug 2007 06:20 AM — 3 posts, 15,789 views.

#0
I am having troubles with a temporary timer that is created inside a trigger, I just can't get it to work. The timer is

AddTimer ("fst_drink",0,0,1,"",timer_flag.Enabled + Timer_flag.OneShot,"resdrink(fst_drink)")

and the function

function resdrink(name)
Note "Enters Function"
if name == fst_drink then
	Note "Checks name"
	if GetVariable("flag_drink") == "1" then 
		SetVariable("flag_drink", "0")
		Note "Checks variable and changes it"
	end
end
end

I have put the little notes to check if the function works.
The weird thing is, if I call the function from the immediate window, it works great, but it doesn't work from the timer. I have checked the send to script option in the trigger window, so that isn't the problem. Any help would be much apreciated.
USA #1
If that's how you're adding it through the script, then the timer doesn't send to script. For that to work properly, either change the send_to with SetTimerOption, or better yet, add the trigger with the ImportXML function


ImportXML
[[
<timers>
  <timer name="fst_drink"
         enabled="y" 
         second="1" 
         send_to="12"
         one_shot="y" >
  <send>resdrink(fst_drink)</send>
  </timer>
</timers>
]]

Amended on Mon 06 Aug 2007 07:06 AM by Shaun Biggs
#2
I've got it to work, the problem was that I couldn't send the name of the timer to the function it called.
Edit: the correct timer, in case someone finds it useful:

AddTimer ("fst_drink",0,0,1,"",timer_flag.Enabled + 
Timer_flag.OneShot,"resdrink")

and the function

function resdrink(name,output,wildcards)
  if GetVariable("flag_drink") == "1" then 
	SetVariable("flag_drink", "0")
  end
end