TriggerHappy
...
- Reaction score
- 341
Most likely it wouldn't get approved and you are probably better off using a static method + indexing (which this is a wrapper for).
The only reason I would think it's useful, is because people are always asking why they can't use methods inside timer callbacks.
Anyways, MethodTimer allows you to simulate methods inside timer callbacks. So you could do something like..
The only rule is the textmacro has to be below the method AFAIK.
Placing it at the bottom of the struct would be fine.
Here's the script code...
EDIT: erm, now that I look at it it's crap.
The only reason I would think it's useful, is because people are always asking why they can't use methods inside timer callbacks.
Anyways, MethodTimer allows you to simulate methods inside timer callbacks. So you could do something like..
JASS:
scope MethodTimerTest
private struct data
timer t = CreateTimer()
method displayIndex takes nothing returns nothing
call BJDebugMsg(I2S(this)) // Displays 1 every second
endmethod
static method onInit takes nothing returns nothing
local data d = data.create()
call thistype.displayIndexPeriodic(d.t, 1.00, true, d)
endmethod
//! runtextmacro METHOD_TIMER("displayIndex")
endstruct
endscope
The only rule is the textmacro has to be below the method AFAIK.
Placing it at the bottom of the struct would be fine.
Here's the script code...
JASS:
library MethodTimer
globals
public hashtable HASH = InitHashtable()
endglobals
//! textmacro METHOD_TIMER takes FUNC_NAME
static method MethodTimer_call_$FUNC_NAME$ takes nothing returns nothing
call thistype(LoadInteger(MethodTimer_HASH, GetHandleId(GetExpiredTimer()), 0)).$FUNC_NAME$()
endmethod
static method $FUNC_NAME$Periodic takes timer t, real timeout, boolean periodic, integer index returns nothing
call SaveInteger(MethodTimer_HASH, GetHandleId(t), 0, index)
call TimerStart(t, timeout, periodic, function thistype.MethodTimer_call_$FUNC_NAME$)
endmethod
//! endtextmacro
endlibrary
EDIT: erm, now that I look at it it's crap.