Hi all,
Let me show you another proof of concept (PoC) Lua code I worked on yesterday and part of today. This time I rewrote
@Prof. Garfield 's LST LuaCore/
helpKey.lua to meet my own reporting needs. I know I should avoid modifying the LuaCore code but this time I had to as I wanted enhanced unit reporting capabilities.
This is the existing LST help key info, which is already amazing and gives the info available in the Civilopedia plus the current hit points and nearest friendly city:
And this is my new Unit Status report (helpkey). I'm still struggling with font alignment but it's the best I could get for now, will continue fine tuning it. It's completely dynamic text, nothing is hardcoded except some fixed labels. I have a section for the specific unit info, then two sections related to the unit type:
How it works: I modified both helpKey and helpKeySettings to be able to define a table of images for each unit type. Also I have an object for a brief text description of each unit type.
As you know, my scenario caters for specific unit IDs in case of ships or leaders (I implemented this for my espionage module), so if a specific unit ID (dependiing on their domain) has been defined in the different parameter tables, I will show the unit name, in this case the ship name.
All these centered headers which split the sections gave me some headaches. I had to code some lpad, rpad and pad functions and define separators and max chars per line, and it's still not perfect because of the different character width, but hey, it is what it is.
For the different columnar info, I'm using
@Knighttime 's
convertTableToColumnText functionality included in the LST text module, playing around with different tables and alignments in the different sections of the page.
Now the fun part: the unit Location text will change depending on the unit domain, and current unit situation, e.g. if it's in a city or outside it. I programmed a quick function to return the relative direction respect of the closest city (irrespective of friendly or enemy city) and I really like it in-game.
The distances shown are quite accurate, as my map is done in a way that each tile is roughly 10x10 km in real life, so it's easy to convert to actual distances.
For planes, we get different texts too:
Also if it's not an "unique unit", then I just show the unit id.
Ground units:
For damaged units, the status and strenght changes:
That's all for now!
Pablo