Trying to update tables at top of file

Carl_Bar

Chieftain
Joined
Nov 15, 2014
Messages
49
The various xml files have tables at the top, based on an error i'm getting and past experience with modding other games these define various things that appear in the table below. All fine and dandy. However as a result of something i've changed i now need to add an entry to this table and i can't figure out how with the where and set commands, would like some help.

Cheers.
 
From the XML/SQL Cheat Sheet for Civ5:
Note there are 2 different syntaxes for XML (compare the first 2 examples vs. the third); you can use either, or mix them. Or you can use SQL syntax instead.
Updating rows

XML
Code:
<GameData>
	<Colors>
[COLOR="Gray"]<!-- Changes the red channel for all colors named COLOR_CUSTOM (there is only one actually) -->[/COLOR]
            <Update>
                <Where Type="COLOR_CUSTOM"/>
                <Set Red="1"/>
            </Update>
[COLOR="gray"]<!-- You can specify as many conditions as you want and set as many properties as you want -->[/COLOR]
            <Update>
                <Where Type="COLOR_CUSTOM" Red="0"/>
                <Set Red="1" Green="0"/>
            </Update>
[COLOR="gray"]<!-- As always, formatting rules are relaxed, use what's the most convenient for you -->[/COLOR]
            <Update>
                <Where>
                    <Type>COLOR_CUSTOM</Type>
                </Where>
                <Set>
                    <Red>1</Red>
                    <Green>1</Green>
                </Set>
            </Update>
        </Colors>
</GameData>
SQL
Code:
[COLOR="gray"]/* Update all colors whose names are COLOR_CUSTOM and red channel is 0 */[/COLOR]
UPDATE Colors
SET Red = 1, Green = 0
WHERE TYPE = 'COLOR_CUSTOM' AND Red = 0;
 
[COLOR="gray"]/* Makes everything brighter */[/COLOR]
UPDATE Colors
SET Red = Red + 0.1, Green = Green + 0.1, Blue = Blue + 0.1;
 
I read your post again, and I think you're confused about how this is supposed to work. You can't just add a new column to the table and expect the game to know what to do with it. Maybe you could explain what you're trying to do.
 
Ok i'm trying to add a free perk to a unit, unfortunately the effect isn't one of those listed in the unit perk file, it's in the promotions file. Since the effect allready exists in the game i'd assume i just need to add a new column to the unit perks table, (appropriate sub table obviously), so the game can recognize the modifier down in the perks section.

Unfortunately i can't figure out how to use the Where and set commands on the following code, it just throws a whole bundle of errors at me in the SDK about unexpected this and unexpected that and lack of whitespacing, (I've even had it say "no whitespace error, put a space in and had it throw "unexpected whitespace" at me).

The code i want to add to the table and the table header code is below:

Code:
		<Table name="UnitPromotions">
			<Column name="DefendRangedMod" type="integer" default="0"/>
		</Table>
 
Just because column X exists in table Y doesn't mean you can add column X to table Z and expect the game core (C++ code in the compiled DLL) to understand what to do with it.

It would be a bit like taking a parcel to the library and expecting them to deliver it (that's the job of the postal service).

To add a new column to a table not only do you need to use SQL to do it (ALTER TABLE ...) but you will also need to write all the lua (as we don't have the C++ source for the DLL at the moment) to process the information in that new column for that table.

TL;DR - it doesn't work like that.
 
To add a column to a table, you can use SQL with ALTER TABLE, but like I suggested above, that's not how programming works. The game can't do anything with data it isn't expecting.

EDIT: [the above was ninja'd, but note:]

You should be warned that there are issues with adding promotions in BE causing the unit action interface to disappear. Hopefully Firaxis will fix this, but I'm not holding my breath that it will be soon.

All that being said, there is already an equivalent column in the Unit Promotions table, but it's called "RangedDefenseMod." And, anyway, why can't you use the DefendRangedMod perk?
 
@whoward69: i'd assumed it, (the entry in perks), might reference back to some core, (presumably c++), file and that if i added it to promotions it would recognize it that way. If it didn't well at least i'd tested and checked, that's how i do a lot of modding beyond learning the bare basics, try crazy stuff see if it works, (such as adding over a 1000 hardpoints to a single model file in HW2 for example :p).

@Nutty: missed that, thanks, i'd assumed that the reference was unique so didn't look for a separate one.
 
Back
Top Bottom