Adding a new value to a def during Save / Load

Started by SickBoyWi, May 28, 2021, 03:48:25 PM

Previous topic - Next topic

SickBoyWi

I'm trying to add a new value to the FactionDef, specific to the player faction. It's a single integer value. I've explored several options, but thus far have not see a good solution.

Looks like DefModExtension cannot be loaded from a save file, so using that seems out.

Is there a way to do this? Effectively I'm tracking a value in my mod, and need to be able to restore it in between save/shut down/reloads. The value is specific the player faction, but I'm tracking it in a static mod class.

Any thoughts or ideas are welcome and appreciated!

RawCode

there are map and world components, what exactly wrong with using them?

SickBoyWi

I think I'm going to use a QuestScriptDef that stays alive for a while. It seems fitting, since it is effectively a global quest for the mod in question.

The issue with the map and world components are that the player may not have a base at given time due to the nomadic nature of the pawns in the mod, and there won't be a specific world object associated with things.

I'm trying to make the player have to destroy so many bases of a specific other faction. So I need to keep a count of how many they've destroyed to date, keep that data in between game loads. The Quest stuff should work great here.

Thanks for the answer.

RawCode

there are plenty global and persistent things, you can go directly and extend faction class with your custom code that will handle everything directly

i just can't understand what exactly issue you have, if you want to implement something like this without code, with XML only, you can't.

with code, there are absolutely no issues with tracking saving and loading, game have all required methods that can monitor both saving and loading.
also there are methods to save and load arbitrary data as custom payload

with a bit of skill, you may save required data "offsave" as part of mod configuration and ever if player keep multiple saves and reload multiple times, all trackers will stay persistent.