Would like to know the syntax for ...

Daddicus

Chieftain
Joined
Aug 28, 2010
Messages
47
I'm trying to figure out the syntax for replacing values in XML. I'll use the following code as an example. I'm showing the data from the original XML file for just one technology, but the syntax will apply to all of them. Here's the XML:

Code:
	<Technologies>
		<Row>
			<Type>TECH_POTTERY</Type>
			<Cost>35</Cost>
			<Description>TXT_KEY_TECH_POTTERY_TITLE</Description>
			<Civilopedia>TXT_KEY_TECH_POTTERY_DESC</Civilopedia>
			<Help>TXT_KEY_TECH_POTTERY_HELP</Help>
			<Era>ERA_ANCIENT</Era>
			<Trade>true</Trade>
			<GoodyTech>true</GoodyTech>
			<GridX>1</GridX>
			<GridY>1</GridY>
			<Quote>TXT_KEY_TECH_POTTERY_QUOTE</Quote>
			<PortraitIndex>4</PortraitIndex>
			<IconAtlas>TECH_ATLAS_1</IconAtlas>
			<AudioIntro>AS2D_TECH_POTTERY</AudioIntro>
			<AudioIntroHeader>AS2D_HEADING_TECH_POTTERY</AudioIntroHeader>
		</Row>

Now, let's say I want to change the cost of pottery from 35 to 40 (or 30 or whatever). What is the proper syntax for such a change?

The second thing I might want to do is add an entry. In the above, "trade" is set to true. I couldn't find a tech in the list for this example, but please assume that pottery was not set to trade=true by the game. How would I ADD an element later to turn trading on if that were the case?

Finally, if I wanted to look up this syntax question for myself in some reference material somewhere, where could I look?

Thanks!!!
 
Now, let's say I want to change the cost of pottery from 35 to 40 (or 30 or whatever). What is the proper syntax for such a change?

Like so:
Code:
<GameData>
  <Technologies>
    <Update>
      <Set Cost="40"/>
      <Where Type="TECH_POTTERY"/>
    </Update>
  </Technologies>
</GameData>

Very simple. If you want to change multiple things at once, just stack them into the Set. So <Set Cost="40" GoodyTech="false"/> will both set the cost to 40 and disable this as a possible goody hut reward.

How would I ADD an element later to turn trading on if that were the case?

If you mean "How do I change an existing tech to have this turned on", it's just a standard Update, with "<Set Trade="true"/>" as the Set line. Note that this particular line has a Default="false" declaration in the table definition, so any techs that don't have it set in their Row definition DO have a value for it in the database, so the Update syntax will work just fine.

If you mean "How do I turn tech trading on?", that's a totally different thing. That <Trade> line doesn't mean that the tech enables trading, it only means that if tech trading IS on, then this is flagged as one of the tradeable techs. Given that it looks like tech trading was never finished (I think it's missing the UI interface part), you'd have to do a lot more than just change an <EnableTechTrading> XML entry.

If you mean "How do I add a new element to the XML table", you don't. Well, you can, but you'd have to write the Lua logic to parse it yourself, and there are all kinds of compatibility issues involved for people using multiple mods. Depending on what you're trying to do with it, you're often better off making a separate table.
 
Thank you very much! That's exactly what I needed. (I wanted the first of your two "trade" choices.)

What I'm trying to do is just learn the "language" (XML). I figured simple things could get me started. Thanks!!!
 
Two more questions:

For the "Where xxx=yyy" line, can multiple entries be put on the same line? (for example, <Where Tech="TECH_POTTERY" Tech="TECH_SAILING">, etc.)

If not, I assume I'll need a Set and a matching Where for each tech I would want to change. Would I also need to surround them with update brackets?
 
For the "Where xxx=yyy" line, can multiple entries be put on the same line? (for example, <Where Tech="TECH_POTTERY" Tech="TECH_SAILING">, etc.)

No. Multiple entries on a Where line indicate an AND syntax, where it'll only trigger the Set if a single Row meets ALL of the criteria. (Since a tech can't be both Pottery and Sailing, doing it your way would result in nothing being changed.) This format is useful for many of the secondary tables, like the Flavors table:
Code:
<Set Flavor="10"/>
<Where TechType="TECH_POTTERY"/>
would change every Flavor entry for that particular tech to 10, which isn't usually what you want. If you only wanted to change a single one, you'd use something like <Where TechType="TECH_POTTERY" FlavorType="FLAVOR_GROWTH"/>.

Now, if you want to have a change that applies to multiple techs, you sometimes CAN do that, depending on the exact techs in question. A Where doesn't have to key off the Type field; you can use any field in the table. So you could use
<Where Era="ERA_ANCIENT"/>
or
<Where GridX="1"/>
to adjust a whole block techs at once. But generally speaking, it's safer to just use multiple Update blocks, one per tech. Leave the sweeping changes to SQL mods, that's what they're built for.

Would I also need to surround them with update brackets?

Yes, with a separate Update block around each one (same as for Row declarations). So it'd look like:
Code:
<GameData>
  <Technologies>
    <Update>
      <Set Cost="40"/>
      <Where Type="TECH_POTTERY"/>
    </Update>
    <Update>
      <Set Cost="80"/>
      <Where Type="TECH_SAILING"/>
    </Update>
  </Technologies>
</GameData>
 
Finally, if I wanted to look up this syntax question for myself in some reference material somewhere, where could I look?

Thanks!!!

To answer this, the best place is probably Kael's guide. It is located at the top of the tutorials subforum... or you can just click here:

http://forums.civfanatics.com/showthread.php?t=385009

Note, the file is a PDF so you will need Adobe Acrobat Reader, at the least (or another program that reads PDFs. It covers a lot of the basics, though I would say that it hardly scratches the surface. Still, it goes into adding new objects like civilizations and such. Definitely worth checking out!
 
Thanks! That should do it! (I tried the multiple per line while waiting for a post, and it failed as predicted.)
 
Hi Daddicus,

I recommend you the SQLite Manager, a FireFox plugin for browsing SQL databases. You'll find the CiV database in
My Games / Sid Meier's Civilization V / cache
(.db suffix)
Choose Civ5DebugDatabase.db.

Sidnote to Kael's Guide:
If you wanna implement files, which replace original files or had to be copied into the original file directories, you have to set the "Import into VFS" flag to true (ModBuddy, click on the file -> Properties). It's not mentioned in the guide and some examples just don't work without this step.
 
Hi Daddicus,

I recommend you the SQLite Manager, a FireFox plugin for browsing SQL databases. You'll find the CiV database in
My Games / Sid Meier's Civilization V / cache
(.db suffix)
Choose Civ5DebugDatabase.db.

Sidnote to Kael's Guide:
If you wanna implement files, which replace original files or had to be copied into the original file directories, you have to set the "Import into VFS" flag to true (ModBuddy, click on the file -> Properties). It's not mentioned in the guide and some examples just don't work without this step.

Is there something available for non-Firefox users?
 
Top Bottom