Name | Type | is_array | initial_value |
Casts | integer | Yes |
--[[ TasAbilityChargeBox V1 by Tasyen
Adds a custom ChargeBox over Command Buttons to display a Number
requires loading a fdf/toc containing "TasAbilityChargeBox"
incorrect display when commandbutton Positions colide or in Group selection
function TasAbilityChargeBox.SetValue(unit, spellCode, value)
enforce a wanted Value for that spellCode for unit
function TasAbilityChargeBox.GetValue(unit, spellCode)
function TasAbilityChargeBox.Clear(unit)
function TasAbilityChargeBox.Init()
]]
do
TasAbilityChargeBox = {
Data = {}
,Unit = {}
}
local tocPath ="war3mapImported/TasAbilityChargeBox.toc"
local updateIntervale = 0.2
local this = TasAbilityChargeBox
local data = this.Data
function this.SetValue(unit, spellCode, value)
if not data[unit] then data[unit] = {} end
data[unit][spellCode] = value
end
function this.GetValue(unit, spellCode)
if not data[unit] then return 0 end
return data[unit][spellCode] or 0
end
function this.Clear(unit)
data[unit] = nil
end
function this.Update()
local unit = this.Unit[GetLocalPlayer()]
for i=0,11 do
BlzFrameSetVisible(BlzGetFrameByName("TasAbilityChargeBox", i), false)
end
-- One wants to display something specific?
if data[unit] then
for spellCode, value in pairs(data[unit]) do
local pos = BlzGetAbilityPosX(spellCode)+ BlzGetAbilityPosY(spellCode)*4
BlzFrameSetVisible(BlzGetFrameByName("TasAbilityChargeBox", pos), true)
BlzFrameSetText(BlzGetFrameByName("TasAbilityChargeBoxText", pos), R2I(value))
end
end
unit = nil
end
function TasAbilityChargeBox.Init()
TimerStart(CreateTimer(), updateIntervale, true, this.Update)
this.Create()
if FrameLoaderAdd then FrameLoaderAdd(this.Create) end
local trig = CreateTrigger()
TriggerAddAction(trig, function() this.Unit[GetTriggerPlayer()] = GetTriggerUnit() end)
TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SELECTED)
this.Trigger = trig
end
function this.Create()
BlzLoadTOCFile(tocPath)
local frame
for i=0,11 do
frame = BlzCreateSimpleFrame("TasAbilityChargeBox", BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, i), i)
-- reserve HandleId, used Async later
BlzGetFrameByName("TasAbilityChargeBoxText", i)
BlzFrameSetVisible(frame, false)
end
if GetHandleId(frame) == 0 then print("TasAbilityChargeBox - Error Creating Frames") end
end
end