How to set description dynamically

NameArleadyUsed

Chieftain
Joined
Mar 12, 2016
Messages
99
Location
Europe, Earth, Solar System
I plan to add some similar info to unit descs but wonder if there is any way to do it with one generic querry.
I tried something like this:
Code:
UPDATE Units SET Description=Description+'LOC_MYNEWCLASS_DESCRIPTION' WHERE EXISTS (SELECT * FROM TypeTags WHERE Units.UnitType=TypeTags.Type AND TypeTags.Tag='CLASS_MYNEWCLASS');
but in-game result is "0" instead of any text (well, "0" is a one digit text but you know what I mean :mischief:).
Any idea how to realise the goal? Or even make it work with localizations?
 
Try to replace + with || for string concatenation.

My guess is that sqlite convert both string to number when using +
 
Eh, it worked somehow but since there is no
Code:
LOC_UNIT_SWORDSMAN_DESCRIPTIONLOC_MYNEWCLASS_DESCRIPTION
in BaseGameText game shows above raw name in place of desc.
I thus assume that due to the way the game works (level at which database querries are interpretted) it is impossible to achieve desired effect. Right?
 
Yes, sorry, missed that point, try it directly on the localization database (you can use SQL in that context) and on the text column.

Edit: ho, yes you're right can't be used in that context as the select won't work...
 
I don't think the Gameplay database can talk to the Config database at all, which is somewhat annoying when you want to dynamically add text. E.g. there is no way I know of to create a "Logistics" mod and a "New Units" mod where the Logistics mod makes changes to a class of units (e.g. all Siege units), and then text descriptions can be easily passed to the Units mod without knowing precisely the names of every unit the Units mod will add. So, for the leader selection screens this is out.

Within the Gameplay database, you might be able to get sneaky and pass a value dynamically by abusing the NAME or DESCRIPTION fields. In particular, abusing the ModifierStrings table to pass a string describing which units to make text changes to, and then in a Text sql file somehow interepreting that and converting it to a sql query that affects the correct units. I have not tried this.
 
A possible solution for a large mod is to have configuration tables in one sql file in which you put all the new data for your mod, then load that file in each database (same file referenced in config, gameplay and text in the modinfo) and finally use specific sql files to update each database with the relevant part.

Once set with loading order you just need to edit one file and the changes will be dynamically applied to all databases.
 
Back
Top Bottom