-
Notifications
You must be signed in to change notification settings - Fork 0
generate_start_condition
I wanted to create a new startconditions.xml mod, but I didn't want to hand-edit an XML file to do it. After thinking about it, I realized that a starting condition was pretty close to a savefile, so I could just transform saves into startconditions using a script.
The script creates reads the world.xml from a savefile, and does some analysis on it. Some rules are applied, and the data from your saved things are converted to startconditions.xml entries. The output is piped back to stdout, so you'll have to either redirect it to a file, or pipe it into another process from there (this is because I don't like hand-entering paths in args)
the usage is as follows:
> pipenv run python StationeersSaveFileDebugTools.py generate_start_condition --help
Usage: StationeersSaveFileDebugTools.py generate_start_condition
[OPTIONS] WORLD
Options:
--help Show this message and exit.
The arguments are:
WORLD: The world.xml from your savegame
The rules are pretty straightforward, but two classes of entries are written, PlayerInventory and InitialSpawn. The file generated makes these entries available under the ConditionKey Generated.
This section describes the inventory that each character receives when they initially spawn into a server.
The script grabs the first Character entry it finds in the savefile, and treats that characters configuration as the initialspawn conditions for all players under the start condition. Some Caveats:
- The script only loads one character, even if there are multiple
- The script will (probably) break if there is no character in the save
- No attention is paid to the species of the character, if you want this feature let me know in the issues
- Pay attention to what is in the character's hands, because these will become part of the start condition as well
This section describes the items that are populated into the environment when the world is first created. For this script, we only generate landers with attached crates and gas tanks. Landers are automatically generated based on the number of crates you're spawning into the environment and the number of gas tanks. Right now there's no way to assign specific crates to specific landers, the script will create and fill new landers as needed to deploy the crates indicated in your savefile.
Again, caveats:
- Any crate that is labeled "exclude" (using the in-game labeler) will be ignored
- Only the prefab information is stored, so if you fill a custom mix into your Gas Tank, it will be lost. If a crate contains an,
ItemGasCanisterOxygenthe mod will create a new, full oxygen tank when the new world is created, but if there is aItemGasCanisterEmpty, it will be empty, regardless of the contents of the canister in your create - Battery charge states and object damage states are also ignored by the system
It's pretty straightforward to try. In the repo there's a sample file, just enter:
> pipenv run python StationeersSaveFileDebugTools.py generate_start_condition Data/ConditionGenerator/world.xml > startconditions.xml
This will generate a new startconditions.xml file in your current directory. You can then paste that into your mod (see the modding examples bundled with the game) and it will load when the mod is loaded.
When creating a new world, be sure to specify "Custom World" and in the "Starting Condition" field, specify "Generated"
If you have any issues, questions, or suggestions, add them to the Issue Tracker
Why build this?
I hate manually editing XML files, and I wanted to test some of my assumptions about save files for future scripts/mods. That's pretty much it, if you find it useful, that's great!
Why aren't states (gas contents, damage, charge level) saved?
Right now, it doesn't look like the mod system for start conditions supports this.
Can I use the generated file to replace my default
startconditions.xml?
That is a very bad idea, I suspect it will break a bunch of parts of your game. This is intended for use in mods only