Help? Updating xml not working

TheManFromMars

Warlord
Joined
Oct 25, 2010
Messages
102
Hi there,
I'm just trying to do something simple like updating the size (scale) of a unit so it looks gigantic on the map.

This is my code:
<GameData>
<UnitMemberArtInfos>
<Update>
<Where>
<Type>ART_DEF_UNIT_MEMBER_WORKER</Type>
</Where>
<Set>
<Scale>0.36</Scale>
</Set>
</Update>
</UnitMemberArtInfos>
</GameData>
(Sorry for the poor formatting, it's formatted properly in ModBuddy)

I'm just trying to make the standard worker unit really big as a test.
I don't see what I'm doing wrong, just to cover my bases I've set VFS=true and tried it on false too. I have reload units on (well I've got reload everything on) so I feel like it should be working.

Any help would be greatly appreciated.
-Mars
 
You've got the name of the table wrong. Don't feel bad, the unit art define XML confuses things by not mapping directly to the database because Firaxis uses intermediate templates.

As I mentioned to you before (and it's especially important for the unit art defines), look at the database with a SQLite browser when you're unclear.

EDIT: whoward69 was kind enough to export the base game's database to properly formatted XML for modders to use as templates.

Code formats properly if you put it in [ CODE ] blocks.
 
Hi Nutty,
Thanks again for the reply. I've never really dabbled in the SQL side of things so it's rather alien to me - I've done plenty of programming etc but I started years and years ago with XML with Civ4 etc and just stuck with it.

So I don't know how the use of the SQLite browser would help, I'm still not sure what I'd be looking for you see? It's just frustrating because I feel like nothing is logical! You go to do something logical and it doesn't work, this has been my experience of modding Civ since Civ 5.

And I've no idea what you mean by
Code:
 blocks - I'm sorry I don't know this stuff, it's just all my modding has been very xml and 'workaround' based, I don't feel like I've been making Civs/mods for nearly 10 years :( 

-mars
 
Sorry for taking so long to reply and for the initial lack of clarity.

My recommendation has nothing to do with learning or using SQL syntax (though I have personally found it very useful).

A database browser allows you to see the database as a collection of interrelated tables, with the data organized into, well... tables. It can be a crucial troubleshooting tool to actually see what the effects of your mod are on the data, but it's also helpful to be able to look at the database structure, especially where the XML doesn't actually look like the finished data, as in the case of the unit art defines and audio defines.


If you post code on the forums, put [ CODE ] before and [/ CODE ] after (or if you're in advanced edit mode, then you could select and hit the # hash mark button) to maintain spacing and prevent word wrapping (not to mention to prevent the insertion of a space after 50 characters without one).
 
I think what Nutty is trying to get to is if you were to look at the table via a db browser then you would have noticed any differences in your xml file and the database.

The xml is nothing but a query really, in your xml above your telling the game loader to do basically the following (which is translated by the loader to sql)

Code:
<?xml version="1.0" encoding="utf-8"?>
<GameData> <!-- in game date -->
    <UnitMemberArtInfos> <!-- table UnitMemberArtInfos --> 
        <Update> <!-- i want to update -->
            <Where> <!-- where -->
                <Type>ART_DEF_UNIT_MEMBER_WORKER</Type> <!-- Type = 'ART_DEF_UNIT_MEMBER_WORKER' -->
            </Where>
            <Set> <!-- set -->
                <Scale>0.36</Scale> <!-- Scale = '0.36' -->
            </Set>
        </Update>
    </UnitMemberArtInfos>
</GameData>

which the game loader puts all together as,

Code:
UPDATE UnitMemberArtInfos SET Scale = '0.36' WHERE type = 'ART_DEF_UNIT_MEMBER_WORKER';

then it runs that against the SQLite database that runs the backend of the game. Now there are two things with what you have here that we should point out. One is there isn't a table named "UnitMemberArtInfos" which you would have noticed with the SQL Browser or looking at the Database.log file (assuming you have debugging turned on). Because that's what i used to find out that the table name is actually "ArtDefine_UnitMemberInfos". Also in the Database.log file it was throwing the following errors.

Code:
[276399.997] no such table: UnitMemberArtInfos
[276399.997] In Query - UPDATE UnitMemberArtInfos SET "Scale" = ? WHERE "Type" = ?;
[276399.997] Database::XMLSerializer (Game Rules1.xml): There was an error executing the update statement! See Database.log for details.
[276399.997] In XMLSerializer while updating table UnitMemberArtInfos from file Game Rules1.xml.

So it can help a lot to use a SQLite browser to find the info you need. Also when the game loads up you can then open the CivBEDebugDatabase.db file and look to make sure your changes were indeed accepted and are reflecting in the database. Now keep in mind that this is a copy of the database that the game is actually using. So any new units created and such are not reflected in this database. But it's there to show you what info it's working with and how all the mods have altered the game data.

Viewing the database isn't a hard thing and much easier then people might first believe. Just download http://sqlitebrowser.org/ or any other DB Browser that supports SQLite. Once installed click the "Open Database" button which will open an explorer window navigate to C:\Users\<username>\Documents\My Games\Sid Meier's Civilization Beyond Earth\cache and you should see all the databases there that CivBE uses. Once you open the DebugDatabase or Core you'll get an excel style table. Along with a dropdown at the top which is all the tables in the database. There you can find your ArtDefine_UnitMemberInfos table. The load up the game with your mod and check in the DebugDatabase after the game loads to make sure your new value has been updated.

Hope this helps!
 
Back
Top Bottom