Originally Posted by dragonclaw7000
Thanks a lot Works like a charm. ThoughI would like some clarification how to transfer variables from one function to another. This do not give any errors but it won't work:
The idea is to transfer the values of the event arguments to the UpdateCooldown function.
Code:
function TrapTimer:UpdateCooldown(spell_caster, spell_name, spell_rank)
if spell_caster == "player" then
if spell_name == "Holy Light" then
TrapTimer.bar2:SetValue(0)
end
end
end
function TrapTimer:EventHandler(...)
if event == "PLAYER_ENTERING_WORLD" then
TrapTimer:Initialize()
end
if event == "UNIT_SPELLCAST_SUCCEEDED" then
ChatFrame1:AddMessage("YEz!")
local arg1, arg2, arg3 = ...
TrapTimer:UpdateCooldown(arg1, arg2, arg3)
end
end
|
in you TrapTimer:EventHandler() I would pass "event" by changing it too:
Code:
function TrapTimer:EventHandler(event, ...)
instead of doing
Code:
local arg1, arg2, arg3 = ...
TrapTimer:UpdateCooldown(arg1, arg2, arg3)
you could instead pass the vararg (...) to TrapTimer:UpdateCooldown().
so
Code:
TrapTimer:UpdateCooldown(...)
or you could create an upvalue of arg1, arg2 and arg3 and pass them to TrapTimer:UpdateCooldown()
Code:
TrapTimer:EventHandler(event, arg1, arg2, arg3)
blah
TrapTimer:UpdateCooldown(arg1, arg2, arg3)
end
as a final note the method notation automatically passes the variable "self" which is the same as the table holding the function.