Hi. I'm having a timer, which executes function. The problem is that the function needs a variable of type group. I can't pass parameters to function in timer. There has to be way to pass a local variable to function.
Use Kattana's Handling system. Look into my Divine Intervention spell (yeah right...) and try to look for one timer. You should see some stuff like call StoreHandle() or GetLinkedUnit(). StoreHandle must be used like this:
But in Divine I. the handler functions are other. There are for example GetLinkedUnit. Kattana's GetHandleHandle doesn't work for units. Can I use your handler functions? Or maybe there is a way for GetHandleHandle to work?
EDIT : No matter. I found it was the Vexorian's vars not Kattana. Kattana vars have SetHandleUnit functions.
Copy the code from me and if you want to pass the unit do like this (btw... you will need to copy the codes which apply to the entire map which can be found in the trigger editor - click on the map icon on the left panel to find it into my map.
Take that script (ENTIRELY) and copy-paste it into your map. Now create a global variable called cache (CASE SENSITIVE) and which is Game Cache global. Ok, now to take the script, here is an example which work with a timer:
function Tim takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit cast = GetLinkedUnit(t, "cast")
call DisplayTextToForce( GetPlayersAll(), UnitId2StringBJ(GetUnitTypeId(cast)) )
set cast = null
set t = null
endfunction
function Main takes nothing returns nothing
local timer t
local unit cast
set cast = GetTriggerUnit()
set t = CreateTimer()
call StoreHandle(t, cast, "cast")
call TimerStart(t, 0.01, true, function Tim)
call TriggerSleepAction(1.00)
call Flush(t) //Needed to avoid further leaks. Use it before you destroy the timer/trigger etc.
call DestroyTimer(t)
set t = null
set cast = null
That should give you slight idea about using it with timers. With triggers situation is like this. I didn't make a real trigger but instead I gave it only an action. Put the event and condition you like.
function Trig takes nothing returns nothing
local unit cast = GetLinkedUnit(GetTriggeringTrigger(), "cast")
call RemoveUnit(cast)
set cast = null
call Flush(GetTriggeringTrigger())
call DestroyTrigger(t)
set t = null
endfunction
function Main takes nothing returns nothing
local unit cast
local trigger t
set cast = GetTriggerUnit()
set t = CreateTrigger()
call StoreHandle(t, cast, "cast")
call TriggerAddAction(t, function Trig)
set t = null
set cast = null
The linked units can also be used in condition function.
FlushHandleLocals is a function that will remove all locals set using SetHandleHandle, SetHandleInt, SetHandleString or SetHandleBoolean. Just call it before destroying something that might have locals on it.
You should call it before destroying anything that has locals set on it. You complained about there being no GetHandlerGroup function... it's called GetHandleGroup and it's used like this:
local timer t = GetExpiredTimer()
local group g = GetHandleGroup(t, "myGroup")
Daelin: It's not called the Handling system. It's called the Handle Vars or Local Handle Vars.