I think I know how to get the script to detect what categories the unit has, its just layering the textures I dont know how to do.
Example:
Hooked construction.lua below
- Code: Select all
do
local OldCommonLogic = CommonLogic
function CommonLogic()
OldCommonLogic()
local oldSecChoiceSetControlToType = controls.secondaryChoices.SetControlToType
controls.secondaryChoices.SetControlToType = function(control, type)
oldSecChoiceSetControlToType(control, type)
if __blueprints[control.Data.id].Categories.CONSTRUCTION + categories.FACTORY + categories.ENGINEER then
local ConstBar = '/mods/BattlePack/textures/ui/common/construction_bar.dds'
if DiskGetFileInfo(UIUtil.UIFile('/mods/BattlePack/textures/ui/common/construction_bar.dds')) then
control.ConstBar:SetTexture(UIUtil.UIFile('/mods/BattlePack/textures/ui/common/construction_bar.dds'))
control.ConstBar.Height:Set(48)
control.ConstBar.Width:Set(48)
else
control.ConstBar:SetSolidColor('ff00ff00')
end
else
control.ConstBar:SetSolidColor('00000000')
end
end
local oldSecChoCreateElement = controls.secondaryChoices.CreateElement
controls.secondaryChoices.CreateElement = function()
local btn = oldSecChoCreateElement()
btn.ConstBar = Bitmap(btn.Icon)
btn.ConstBar:DisableHitTest()
LayoutHelpers.AtCenterIn(btn.ConstBar, btn)
return btn
end
local choiceCreateElement = controls.choices.CreateElement
controls.choices.CreateElement = function()
local btn = choiceCreateElement()
btn.ConstBar = Bitmap(btn.Icon)
btn.ConstBar:DisableHitTest()
LayoutHelpers.AtCenterIn(btn.ConstBar, btn)
return btn
end
local choiceSetControlToType = controls.choices.SetControlToType
controls.choices.SetControlToType = function(control, type)
if __blueprints[control.Data.id].Categories.CONSTRUCTION + categories.FACTORY + categories.ENGINEER then
local ConstBar = '/mods/BattlePack/textures/ui/common/construction_bar.dds'
if DiskGetFileInfo(UIUtil.UIFile('/mods/BattlePack/textures/ui/common/construction_bar.dds')) then
control.ConstBar:SetTexture(UIUtil.UIFile('/mods/BattlePack/textures/ui/common/construction_bar.dds'))
control.ConstBar.Height:Set(20)
control.ConstBar.Width:Set(20)
else
control.ConstBar:SetSolidColor('ff00ff00')
end
else
control.ConstBar:SetSolidColor('00000000')
end
end
end
end
However when I tried it, nothing happens :\