| 01-19-2007, 01:34 AM | #1 |
New here. How exactly can I associate a local variable with a function called by a timer? Example: JASS:function LifeDegrade_SetLife takes unit a returns nothing local timer b call SetUnitState( a, UNIT_STATE_LIFE, GetUnitState(a, UNIT_STATE_LIFE) - udg_LifeDegradeRate) call TimerStart( b, udg_LifeDegradeRate, false, LifeDegrade_SetLife) ... I would like to be able to recycle unit a in this function as unit a again after the timer expires, so that this can be run efficiently on multiple units simultaneously. I heard something about using GameCache, but it really isn't clear to me . Help please? |
| 01-19-2007, 01:44 AM | #2 |
| 01-19-2007, 03:39 AM | #3 |
That is the first place I looked, but I don't understand. When you use: JASS:call StartTimer( MyTimer, Interval, false, *functioncalled*) do you put the arguments for *functioncalled* in like this? JASS:call StartTimer( MyTimer, Interval, false, *functioncalled(unit)*) |
| 01-19-2007, 03:56 AM | #4 |
*cough* vex, closures plz k thx |
| 01-19-2007, 12:13 PM | #5 |
JASS:call StartTimer( MyTimer, Interval, false, *functioncalled(unit)*) You cannot pass arguments through the timer callback function. It would work ONLY like this -- JASS:call StartTimer( MyTimer, Interval, false, function MyFunctionRawr) Game cache, special attachments, globals, whatev'. |
