I'm trying to modify the UI to display the shield values in the same way that health values are displayed (EG: Roll over the unit, and you see the health as xxx/yyy, I'm trying to make the shield display the same.)
I have no idea what I'm doing, and I did some studies of the archived GPG posts (what remains of them anyway) and so far I've created a hook file under "lua/ui/game/unitview.lua" -- Here's the code I've written:
- Code: Select all
do
local originalCreateUI = CreateUI
function createUI()
originalCreateUI()
controls.shield = UIUtil.CreateText(controls.shieldBar, '', 14, UIUtil.bodyFont)
end
local originalUpdateWindow = UpdateWindow(info)
function UpdateWindow(info)
originalUpdateWindow(info)
if info.blueprintId == 'unknown' then
return
else
if info.shieldRatio > 0 then
controls.shieldBar:Show()
controls.shieldBar:SetValue(info.shieldRatio)
controls.shield:SetText(string.format("%d / %d", info.shield, info.maxShield))
else
controls.shieldBar:Hide()
end
end
end
end
This completely breaks the game, seemingly. Hitting F9 and I get a mass of errors to do with "right", "top" etc "lazyvars", but right at the top of the pile of errors are things like "can't get global variable "info"" -- Which confuses me because I'm hooking into a script that should already have those variables set up after my code's inserted, right?