WC3 Modding Information Center is being upgraded!! new theme, new layout 100% mobile friendly and more is coming. Please share the rejoice of a new home and give you support through your messages here or in social networks like facebook and Discord

vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation - Zinc documentation - WC3 Optimizer documentation

Hibrid TimerUtils

Guest · 828

Average Score
« Created: October 09, 2017, 12:02:55 AM by moyack »

on: December 20, 2014, 06:49:41 PM
Category: Execution, Variables
Language: vJASS

Related Topics or Resources


This small library allows to attach data structs into timers in an easy way, following the structure proposed by Vexorian, just for compatibility.


 - Microtable
 - Alloc

Actual Code

Code: jass
  1. library TimerUtils requires Alloc, MicroTable
  3. private struct data extends array
  4.     static key K // used to connect the data struct with the variable
  5.     static key D // used to link other data struct to the timer
  6.     timer t
  8.     implement Alloc
  10.     method destroy takes nothing returns nothing
  11.         call PauseTimer(.t)
  12.         call ClearData(.t, thistype.K)
  13.         call .deallocate()
  14.     endmethod
  16.     static method create takes nothing returns thistype
  17.         local thistype this = thistype.allocate()
  18.         if this.t == null then
  19.             set this.t = CreateTimer()
  20.         endif
  21.         call StoreData(this.t, thistype.K, this)
  22.         return this
  23.     endmethod
  25. endstruct
  27. function NewTimer takes nothing returns timer
  28.     return data(data.create()).t
  29. endfunction
  31. function ReleaseTimer takes timer t returns nothing
  32.     call data(GetData(t, data.K)).destroy()
  33. endfunction
  35. function SetTimerData takes timer t, integer d returns nothing
  36.     call StoreData(t, data.D, d)
  37. endfunction
  39. function GetTimerData takes timer t returns integer
  40.     return GetData(t, data.D)
  41. endfunction
  43. endlibrary
« Last Edit: December 19, 2017, 08:00:38 PM by moyack »

We can give you full hosting for your projects, a complete page!!

A custom altered melee map where you can play Naga and Demons. Check it out!!
Use Dropbox...


Power of Corruption - A Warcraft III altered melee map   Chaos Realm - The world of Game modders and wc3 addicts