Hashtable Timer System

hgkjfhfdsj

Active Member
Reaction score
55
http://www.thehelper.net/forums/showpost.php?p=1189499&postcount=10
based on Weep's > wrapper for a hashtable or something:confused: ?

JASS:
function NewTimer takes integer data, real timeout, boolean periodic, code callback returns timer
    if(udg_TimerCount == 0) then
        set udg_TimerStack[1] = CreateTimer()
        set udg_TimerCount = 1
    endif
    call SaveInteger(udg_Hashtable, 0, GetHandleId(udg_TimerStack[udg_TimerCount]), data)
    call TimerStart(udg_TimerStack[udg_TimerCount], timeout, periodic, callback)
    set udg_TimerCount = udg_TimerCount-1
    return udg_TimerStack[udg_TimerCount+1]
endfunction

function GetTimerData takes timer t returns integer
    return LoadInteger(udg_Hashtable, 0, GetHandleId(t))
endfunction

function ReleaseTimer takes timer t returns nothing
    if(t != null) then
        call PauseTimer(t)
        set udg_TimerStack[udg_TimerCount] = t
        set udg_TimerCount = udg_TimerCount + 1
        
    endif
endfunction

function InitTrig_TimerU_Clone takes nothing returns nothing
endfunction

i tried this out with:
JASS:
function time takes nothing returns nothing
    local integer i = GetTimerData(GetExpiredTimer())
    call BJDebugMsg(I2S(i))
endfunction                   

function Trig_Timer_Test_Actions takes nothing returns nothing
    call NewTimer(25, 5., false, function time)
endfunction

//===========================================================================
function InitTrig_Timer_Test takes nothing returns nothing
    set gg_trg_Timer_Test = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Timer_Test, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_Timer_Test, function Trig_Timer_Test_Actions )
endfunction

which i don't even know if im using it right..
- compiles properly >> ie created required globals etc
- shows '0' > assumed that integer was not passed
 

Jesus4Lyf

Good Idea™
Reaction score
397
Initialise [LJASS]udg_Hashtable[/LJASS] (to [LJASS]InitHashtable()[/LJASS]).
ie.
JASS:
function InitTrig_TimerU_Clone takes nothing returns nothing
endfunction

-->
JASS:
function InitTrig_TimerU_Clone takes nothing returns nothing
    set udg_Hashtable = InitHashtable()
endfunction



And for your own sake:
JASS:
set udg_TimerStack[udg_TimerCount] = t
set udg_TimerCount = udg_TimerCount + 1

-->
JASS:
set udg_TimerCount = udg_TimerCount + 1
set udg_TimerStack[udg_TimerCount] = t
 

hgkjfhfdsj

Active Member
Reaction score
55
. . works xD ty
also.. is it me or is it that the stacking index in that system goes backward? or am i wrong? eg shouldnt you increase index by 1 not –1 for every new timer? do arrays have –ve index?
 
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