Discussion Best way to check if a timer is running?

D.V.D

Make a wish
Reaction score
73
I want to make a spell that uses a global timer instead of a separate timer for each spell casted which gets created and destroyed constantly. At the same time, I don't want the timer to run every 0.03 seconds if no spells were casted(may cause a bit of unneeded lag). So I wanted to use a boolean that is enabled when a spell is casted and disabled when no spells are being casted. When the boolean is set to false I want to Pause my timer but I have no clue of how to find out when to enable it again. I thought of maybe using events to detect when the boolean is false or something but Im afraid using another trigger would actually be worse than just having the timer constantly run. Anyone have any suggestions on how to do this?
 

Ashlebede

New Member
Reaction score
43
JASS:
if TimerGetElapsed(t)!=0 and TimerGetRemaining(t)!=0 then
//timer is started
else
//timer ain't started
endif


Try that. Maybe [ljass]PauseTimer()[/ljass] won't change the timer elapsed and remaining, since there is a [ljass]ResumeTimer()[/ljass] native, after all. So you could try this :

JASS:
//whenever the timer is started:
call TimerStart(t,timeout,true,function myFunc)
call SaveBoolean(udg_H,GetHandleId(t),0,true)
//whenever you pause it:
call PauseTimer(t)
call SaveBoolean(udg_H,GetHandleId(t),0,false)


You can check whether it is paused by loading those booleans.
 

Bribe

vJass errors are legion
Reaction score
67
Use Timer32 and your problem is instantly solved; I recommend using it for all of your sfx-timer needs.
 

Trollvottel

never aging title
Reaction score
262
I want to make a spell that uses a global timer instead of a separate timer for each spell casted which gets created and destroyed constantly. At the same time, I don't want the timer to run every 0.03 seconds if no spells were casted(may cause a bit of unneeded lag). So I wanted to use a boolean that is enabled when a spell is casted and disabled when no spells are being casted. When the boolean is set to false I want to Pause my timer but I have no clue of how to find out when to enable it again. I thought of maybe using events to detect when the boolean is false or something but Im afraid using another trigger would actually be worse than just having the timer constantly run. Anyone have any suggestions on how to do this?
just count an integer up when a spell is casted and down when it is finished. if it is 0 you can just pause it.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top