GetTriggerUnit-
DogEntrepreneur
- Reaction score
- 129
This is a very small, but useful snippet that allow the user to remove/destroy a location/effect after the specified amount of time is eslaped.
Requirements:
Jass NewGen Pack 1.5d
TimerUtils
Pros:
Mui
Can be used in Gui
Leakless
Lagless
Cons:
Requires JassNewGenPack
How to use?:
To Use it, call these functions:
Requirements:
Jass NewGen Pack 1.5d
TimerUtils
Pros:
Mui
Can be used in Gui
Leakless
Lagless
Cons:
Requires JassNewGenPack
How to use?:
To Use it, call these functions:
JASS:
call RemoveLocationIn(whichlocation, whichamount of time (Real))
call DestroyEffectIn(whicheffect, whichamount of time (Real))
Trigger:
- Actions
- Custom script: call RemoveLocationIn(whichlocation, whichamount of time (Real))
- Custom script: call DestroyEffectIn(whicheffect, whichamount of time (Real))
Code:
JASS:
library In requires TimerUtils
private struct data
effect ef
method KillEf takes nothing returns nothing
set .ef = null
endmethod
endstruct
private function TimerKillEf takes nothing returns nothing
local data d = GetTimerData(GetExpiredTimer())
call DestroyEffect(d.ef)
call d.KillEf()
endfunction
function DestroyEffectIn takes effect e, real time returns nothing
local data d = data.create()
local timer t
set t = NewTimer()
set d.ef = e
call SetTimerData(t,d)
call TimerStart(t, time, false, function TimerKillEf)
endfunction
//==============================================================================
private struct datae
location lo
method KillLo takes nothing returns nothing
set .lo = null
endmethod
endstruct
private function TimerKillLo takes nothing returns nothing
local datae d = GetTimerData(GetExpiredTimer())
call RemoveLocation(d.lo)
call d.KillLo()
endfunction
function RemoveLocationIn takes location l, real time returns nothing
local datae d = data.create()
local timer t
set t = NewTimer()
set d.lo = l
call SetTimerData(t,d)
call TimerStart(t, time, false, function TimerKillLo)
endfunction
endlibrary
How to Import:
To import, create a new trigger called "In" and paste this following code in it. Also make sure you have TimerUtils
JASS:
library In requires TimerUtils
private struct data
effect ef
method KillEf takes nothing returns nothing
set .ef = null
endmethod
endstruct
private function TimerKillEf takes nothing returns nothing
local data d = GetTimerData(GetExpiredTimer())
call DestroyEffect(d.ef)
call d.KillEf()
endfunction
function DestroyEffectIn takes effect e, real time returns nothing
local data d = data.create()
local timer t
set t = NewTimer()
set d.ef = e
call SetTimerData(t,d)
call TimerStart(t, time, false, function TimerKillEf)
endfunction
//==============================================================================
private struct datae
location lo
method KillLo takes nothing returns nothing
set .lo = null
endmethod
endstruct
private function TimerKillLo takes nothing returns nothing
local datae d = GetTimerData(GetExpiredTimer())
call RemoveLocation(d.lo)
call d.KillLo()
endfunction
function RemoveLocationIn takes location l, real time returns nothing
local datae d = data.create()
local timer t
set t = NewTimer()
set d.lo = l
call SetTimerData(t,d)
call TimerStart(t, time, false, function TimerKillLo)
endfunction
endlibrary