| 02-17-2008, 11:49 AM | #1 |
I know the concept of Local hande vars but I don't know how to apply it to my maps/spells. This handicap is forcing me to use user defined globals(udg) in a script to make the spells work. One ex. of my obstacle is 'something' like this: (might not be accurate) JASS:function knockback takes nothing returns nothing call UnitSetPositionLoc(udg_target, PolarProjectionBJ(.........and so on) endfunction function Bash_Actions takes nothing returns nothing local timer t = CreateTimer() set udg_caster = GetSpellAbilityUnit() set udg_target = GetSpellTargetUnit() call TimerStart(t,0.03,true,function knockback) call TriggerSleepAction(1.00) call DestroyTimer(t) set t = null endfunction Someone tell me how to use Local Handle vars step by step and concisely, I read various tutorials but lead to nothing.. This might help me improve my coding.. TIP: I'm using Kattana's Local Handle Vars cause that's what I use to make some of the spells I use work. Thanks in advance. ![]() |
| 02-17-2008, 11:52 AM | #2 | |
Quote:
I could teach you how to use handle vars, then again I could teach you how to do drugs, but both of them are things I wouldn't like to keep in my conscience. In short, you need to attach some info to the timer and then, in the timer expire function (Since you have GetExpiredTimer) you can get the attached stuff. |
| 02-17-2008, 01:31 PM | #3 |
It might be easier for you to learn TT |
| 02-17-2008, 02:18 PM | #4 |
Not really. In a way it might be harder than Handle Vars, not like that means he shouldn't TT although with a 0.04 seconds timer he could just use his own loop if it is just one spell, would be faster as well. |
| 02-17-2008, 03:53 PM | #5 |
JASS:function knockback takes nothing returns nothing call UnitSetPositionLoc(GetHandleUnit(GetExpiredTimer(),"TheUnitOfMine"), PolarProjectionBJ(.........and so on) endfunction function Bash_Actions takes nothing returns nothing local timer t = CreateTimer() local unit u = GetSpellAbilityUnit() set udg_target = GetSpellTargetUnit() call SetHandleUnit(t,"TheUnitOfMine",u) call TimerStart(t,0.03,true,function knockback) call TriggerSleepAction(1.00) call FlushHandleLocals(t) call DestroyTimer(t) set t = null endfunction The call SetHandleUnit(t,"TheUnitOfMine",u) makes it so that to the timer "t" we attach the unit "u". "TheUnitOfMine" is the key/identifier which we use to get the unit. So, in order to get the unit, we would use call GetHandleUnit(t,"TheUnitOfMine"). Finally, when the spell is over, we have to "clean up" the attached unit. That is done by call FlushHandleLocals(t) |
