Forged Alliance Forever Forged Alliance Forever Forums 2013-10-31T17:01:27+02:00 /feed.php?f=45&t=5660 2013-10-31T07:54:52+02:00 2013-10-31T07:54:52+02:00 /viewtopic.php?t=5660&p=56846#p56846 <![CDATA[Re: Wanting to make a icon script]]> Statistics: Posted by brandonpotter0 — 31 Oct 2013, 07:54


]]>
2013-10-31T17:01:27+02:00 2013-10-31T01:10:24+02:00 /viewtopic.php?t=5660&p=56833#p56833 <![CDATA[Wanting to make a icon script]]>
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:
Image


Hooked construction.lua below
Code:
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 :\

Statistics: Posted by brandonpotter0 — 31 Oct 2013, 01:10


]]>