Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
If you have TESH (I think... might be JASSHelper too) then you can click on a function name while holding ctrl to open that function in the function list...
Opening natives (pink ones) is not very helpfull but BJs (red ones) is.
When you open SetItemLifeBJ() then you see this:
JASS:
function SetItemLifeBJ takes widget whichWidget, real life returns nothing
call SetWidgetLife(whichWidget, life)
endfunction
As you can see there is nothing that is done inside that function so you should use SetWidgetLife() instead.
If you encounter stuff like this:
JASS:
function PolarProjectionBJ takes location source, real dist, real angle returns location
local real x = GetLocationX(source) + dist * Cos(angle * bj_DEGTORAD)
local real y = GetLocationY(source) + dist * Sin(angle * bj_DEGTORAD)
return Location(x, y)
endfunction
You can just stick to PolarProjectionBJ() instead of writing that code everytime to make the trigger more readable and easier to modify.
Timers use an extra function.
That function will be called when it expires.
JASS:
function ItemExpire_Callback takes nothing returns nothing
local timer t = GetExpiredTimer()
call DestroyTimer(t)
set t = null
endfunction
This is an empty callback for a timer. This just removes the timer that expires.
You want to call this callback so you have to start a timer:
JASS:
function ItemExpire takes item whichItem, real seconds returns nothing
local timer t = CreateTimer()
call TimerStart(t, seconds, false, function ItemExpire_Callback)
set t = null
endfunction
As you can see, it is not so hard to start one
Now comes the hashtable part.
You want to let the callback (which will destroy the item) to know what item must be destroyed.
So you use call SaveItemHandle(udg_Hashtable, GetHandleId(t), 0, whichItem) somewhere between "local timer t = CreateTimer()" and "set t = null".
This will save the item in the "udg_Hashtable" under the id of the timer. (which is the only reference that you can use)
Now you have to find out what the callback has to destroy.
The item you have is saved in LoadItemHandle(udg_Hashtable, GetHandleId(t), 0) which you can call somewhere between "local timer t = GetExpiredTimer()" and "call DestroyTimer(t)".
If you would use that item multiple times then you should save it in a variable.
But you will only use it once so we can just say call SetWidgetLife(LoadItemHandle(udg_Hashtable, GetHandleId(t), 0), 0.)
JASS:
function ItemExpire_Callback takes nothing returns nothing
local timer t = GetExpiredTimer()
call SetWidgetLife(LoadItemHandle(udg_Hashtable, GetHandleId(t), 0), 0.)
call DestroyTimer(t)
set t = null
endfunction
function ItemExpire takes item whichItem, real seconds returns nothing
local timer t = CreateTimer()
call TimerStart(t, seconds, false, function ItemExpire_Callback)
call SaveItemHandle(udg_Hashtable, GetHandleId(t), 0, whichItem)
set t = null
endfunction
(btw... "Post Quick Reply"... can someone change that into "Post Long Reply" when you type more than 500 chars? )
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.