Forged Alliance Forever Forged Alliance Forever Forums 2017-01-22T22:44:55+02:00 /feed.php?f=41&t=13880 2017-01-22T22:44:55+02:00 2017-01-22T22:44:55+02:00 /viewtopic.php?t=13880&p=142440#p142440 <![CDATA[Re: Trying to display shield values as a number.]]>
Image

Perhaps it exists in FAF, but I don't use it.

Thanks for the help Speed2, I'll try that out and see if it works out.

Ideally what I want to do is re-do parts of the UI, to show more unit info such as shield values, weapon damage and rate of fire. I would also like to extend the little pop-up box for the unit descriptions when you're mousing over them, so that It can make more use of the available space on screen rather than cramming the descriptions into a little box. Then finally if possible I'm going to try making the little box with unit info remain open for the selected unit -- sort of like in Age of Empires where you can always see the selected unit's stats, whilst still being able to have the mouseover tooltip of other units. It might be a hefty load of work though, I expect I'll have to re-write a lot of the UI but idk. I'll start with the shield values and see what else can be done.

Statistics: Posted by Tanksy — 22 Jan 2017, 22:44


]]>
2017-01-22T22:34:04+02:00 2017-01-22T22:34:04+02:00 /viewtopic.php?t=13880&p=142438#p142438 <![CDATA[Re: Trying to display shield values as a number.]]> 'Display more Units Stats' interface option in game?

I think this will provide what you want (among other stats)

Statistics: Posted by KeyBlue — 22 Jan 2017, 22:34


]]>
2017-01-22T19:31:49+02:00 2017-01-22T19:31:49+02:00 /viewtopic.php?t=13880&p=142427#p142427 <![CDATA[Re: Trying to display shield values as a number.]]> UpdateWindow function in local variable originalUpdateWindow
Code:
local originalUpdateWindow = UpdateWindow


while this calls the function UpdateWindow with parametr info and if the function is returning some value, the value is saved in local variable originalUpdateWindow
Code:
local originalUpdateWindow = UpdateWindow(info)


For hooking the first one is correct

Statistics: Posted by speed2 — 22 Jan 2017, 19:31


]]>
2017-01-22T19:29:46+02:00 2017-01-22T19:29:46+02:00 /viewtopic.php?t=13880&p=142426#p142426 <![CDATA[Re: Trying to display shield values as a number.]]> (info) in that line.
Just like you didn't add () when saving the originalCreateUI

Need to have it like this probably :
Code:
local originalUpdateWindow = UpdateWindow

Statistics: Posted by KeyBlue — 22 Jan 2017, 19:29


]]>
2017-01-22T19:25:46+02:00 2017-01-22T19:25:46+02:00 /viewtopic.php?t=13880&p=142424#p142424 <![CDATA[Re: Trying to display shield values as a number.]]> Statistics: Posted by Tanksy — 22 Jan 2017, 19:25


]]>
2017-01-22T18:35:31+02:00 2017-01-22T18:35:31+02:00 /viewtopic.php?t=13880&p=142423#p142423 <![CDATA[Re: Trying to display shield values as a number.]]> perhaps this line:
Code:
local originalUpdateWindow = UpdateWindow(info)

Statistics: Posted by Myxir — 22 Jan 2017, 18:35


]]>
2017-01-22T17:43:37+02:00 2017-01-22T17:43:37+02:00 /viewtopic.php?t=13880&p=142421#p142421 <![CDATA[Re: Trying to display shield values as a number.]]> Statistics: Posted by Tanksy — 22 Jan 2017, 17:43


]]>
2017-01-22T17:21:18+02:00 2017-01-22T17:21:18+02:00 /viewtopic.php?t=13880&p=142420#p142420 <![CDATA[Re: Trying to display shield values as a number.]]> make sure you set the positions, the game code does this in a SetLayout function in another file
useful for this is the layouthelper lua file which contains a nice amount of helper functions for such stuff

Statistics: Posted by Myxir — 22 Jan 2017, 17:21


]]>
2017-01-22T17:02:18+02:00 2017-01-22T17:02:18+02:00 /viewtopic.php?t=13880&p=142418#p142418 <![CDATA[Trying to display shield values as a number.]]>
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:
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?

Statistics: Posted by Tanksy — 22 Jan 2017, 17:02


]]>