A few questions about the mechanics of loading Civ

KGrevstad

Warlord
Joined
Dec 14, 2005
Messages
110
Location
Pacific Northwest
I was poking through the XML and Python files and a few questions came to mind, and I do apologise if these are answered elsewhere already.

How does Civ know what XML files to load? Are they all well-known files? Does it just load anything that has the .xml extension?

How does Civ load the Python code? Starts with a set of well-known files and then just follows all the imports?

In both cases, are the files' placements in the directory tree critical?

Does XML have any sort of "import" or "include" facility, via perhaps a pre-processor, or are we just stuck with monolithic files?

Someone was asking a few days ago about setters and getters for the XML data. Do these exist in the Python API? Can we dynamically change the value of some arbitrary XML data element?

--Kristine
 
I will try to answer to the best of my ability.

KGrevstad said:
I was poking through the XML and Python files and a few questions came to mind, and I do apologise if these are answered elsewhere already.

How does Civ know what XML files to load? Are they all well-known files? Does it just load anything that has the .xml extension?

The file names and paths are hard coded, you can't just place an xml file in the directory and expect Civ4 to do anything with it.

How does Civ load the Python code? Starts with a set of well-known files and then just follows all the imports?

Yes.

In both cases, are the files' placements in the directory tree critical?

Yes.

Does XML have any sort of "import" or "include" facility, via perhaps a pre-processor, or are we just stuck with monolithic files?

No, there is no inheritence or superclassing for the XML that I am aware of. XML isn't being used to its potential, its just a data store.

Someone was asking a few days ago about setters and getters for the XML data. Do these exist in the Python API? Can we dynamically change the value of some arbitrary XML data element?

--Kristine

There are a lot of set and get commands for known data elements. But if you extend the schema and add a new data element since there are no set and gets commands for that element you can't do much with it.

Check out: http://civilization4.net/files/modding/PythonAPI/index2.html
 
Kael said:
The file names and paths are hard coded, you can't just place an xml file in the directory and expect Civ4 to do anything with it.

One exception: the game parses any XML in the Text directory and loads all the text keys found there. Every other XML file is looked for specifically, though.
 
Back
Top Bottom