TriggerRegisterTimerEventPeriodic

themean

Active Member
Reaction score
7
i using struct like this
JASS:

struct str
trigger t
...
...
...
endstruct

and method create
JASS:

static method create takes real period, code funcs, integer data returns  Timer
local Timer Time=Timer.allocate()
set Time.t=CreateTrigger()
set Time.data=data
call TriggerRegisterTimerEventPeriodic(Time.t, period )
call TriggerAddAction( Time.t,  funcs )
return Time
endmethod

after that
JASS:

function bang takes nothing returns nothing 
call BJDebugMsg(I2S(GetTriggerExecCount(GetTriggeringTrigger())))
endfunction
function Trig_Untitled_Trigger_003_Actions takes nothing returns nothing

call Timer.create(1,function bang,301)
call TriggerSleepAction(1)
call Timer.create(1,function bang,302)
call TriggerSleepAction(1)
call Timer.create(3,function bang,303)
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_003 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_003 = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Untitled_Trigger_003, function Trig_Untitled_Trigger_003_Actions )
endfunction

one of those 3 triggers dont started
if they was 2 will be started
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
library Timer

    struct Timer
        private triggercondition trigCond
        private trigger trig
        integer data
        readonly real period
        
        static method create takes code func, real period, integer data returns thistype
        //callback must return false.
            local thistype this = .allocate()
            local integer i = 0
            set .period = period
            set .data = data
            set .trig = CreateTrigger()
            set .trigCond = TriggerAddCondition(.trig,Condition(func))
            loop
                call TriggerExecute(.trig)
                set i = i + 1
            exitwhen i == this
            endloop
            call TriggerRegisterTimerEvent(trig,period,true)
            return this
        endmethod
        
        method onDestroy takes nothing returns nothing
            call DisableTrigger(.trig)
            call TriggerRemoveCondition(.trig,.trigCond)
            call DestroyTrigger(.trig)
            set .trig = null
        endmethod
    endstruct
    
endlibrary
 
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