call SetData(somehandle,someinteger)
call GetData(somehandle)
//Imagine that grims system is right above this comment.
//! runtextmacro DS_Declare("Unit","unit")
//Now we're able to store units, by using SetUnit(), and getting them again by using GetUnit().
scope test
globals
private timer t
endglobals
function Timer_Actions takes nothing returns nothing
set u = GetUnit(GetExpiringTimer())
call UnitDamageTarget(u,u,15,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHKNOWS)
set u = null
endfunction
function...
local unit u = GetTriggerUnit()
local integer i = GetData(t)
if i == 0 then
call TimerStart(t,0.05,true,function Timer_Actions)
endif
set i = i+1
call SetData(t,i)
call SetUnit(t,u)
set u = null
endfunction
endscope
struct TimedFade
unit fader
integer alpha = 255
integer interval
integer maxinteger
endstruct
function UnitFadeTimedAction takes nothing returns nothing
local TimedFadeData data = GetData(GetExpiredTimer())
if (data.maxinteger > 0) then
set data.alpha = data.alpha - R2I(((0.05*data.interval+1)))
call SetUnitVertexColor(u,data.alpha,data.alpha,data.alpha,data.alpha)
else
call ReleaseTimer(t)
endif
set data.maxinteger = data.maxinteger - 1
endfunction
function UnitFadeTimed takes unit u, real time, real percent returns nothing
local timer t = NewTimer()
local TimedFadeData data = TimedFadeData.create()
if (time == 0) then
call SetUnitVertexColor(u,255,255,255,0)
return
endif
if (percent > 100) or (percent <= 0) then
set percent = 100
endif
if (percent != 100) then
set percent = RAbsBJ(percent-100)
endif
set data.interval = R2I(((data.alpha/time)+1))
set data.maxinteger = R2I((((time*(percent/100))/0.05)+1))
if (data.maxinteger <= 0) then
return
endif
call SetData(t, integer(data))
call TimerStart(t,0.05,true,function UnitFadeTimedAction)
endfunction
The system storage is limited to one handle type per handle right?
Yes agreed, though if your all ready are using the New Gen editor, or vJass in general, I would say that it's easier to simply declare an integer array and an integer for indexing.You could define SetUnit and SetUnit2 and SetUnit3 ad infinitum to attach as many as you wanted, but it makes more sense to just use this to attach integers that point to structs.
struct idu
unit caster
integer level
endstruct
//and then use this?
function whoa takes nothing returns nothing
local timer mytimer = GetExpiredTimer()
local idu mystruct = GetData(mytimer,idu)
endfunction
function TimerStarting takes nothing returns nothing
local timer Blah = CreateTimer()
local idu mystruct = idu.create()
call SetData(Blah,mystruct)
call TimerStart(Blah,3204239.,false,function whoa)
endfunction