
Save function?
Moderator: OpenTTD Developers
Save function?
Could anyone tell me what exactly is saved whenever the game saves itself? If nothing from the GS is saved automatically, is there a Class for this with a GameSave-Event or something like that? I crawled through the NoGo API but didnt find any related events 

- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Save function?
The gamescript doesn't save anything. Just the map state is saved and which game script, AIs and NewGRFs are in use.
EDIT: see Zuu's answer below
EDIT: see Zuu's answer below
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: Save function?
Ok so Challenges, Achievements and such could not be carried over to a savegame... at least not without some dirty tricks ^^
Re: Save function?
You need to store everything that you want to save in a table.
At loading you typically just copy the table and store it in a member variable of the GS/AI and process it later. This is because if you don't return quick enough in the Load function, OpenTTD will kill your AI/GS. Also note that there is an upper limit of how long time you are allowed to spend in the Save function.
In the TileLabels class I have added ExportToSave() and ImportFromSave member functions that allow someone using that library to gather a table representation of the library storage and then to restore it:
http://dev.openttdcoop.org/projects/gsl ... y/main.nut
In TutorialGS you can see an example of how the ImportFromSave is called:
http://dev.openttdcoop.org/projects/gs- ... n.nut#L106
Saving you find here:
http://dev.openttdcoop.org/projects/gs- ... n.nut#L232
At loading you typically just copy the table and store it in a member variable of the GS/AI and process it later. This is because if you don't return quick enough in the Load function, OpenTTD will kill your AI/GS. Also note that there is an upper limit of how long time you are allowed to spend in the Save function.
In the TileLabels class I have added ExportToSave() and ImportFromSave member functions that allow someone using that library to gather a table representation of the library storage and then to restore it:
http://dev.openttdcoop.org/projects/gsl ... y/main.nut
In TutorialGS you can see an example of how the ImportFromSave is called:
http://dev.openttdcoop.org/projects/gs- ... n.nut#L106
Saving you find here:
http://dev.openttdcoop.org/projects/gs- ... n.nut#L232
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: Save function?
so there are actually Load/Save Functions... looked here http://nogo.openttd.org/api/trunk/index.html and there was nothing like this. Not documented yet or is this the wrong documentation?
Re: Save function?
Take a look at the Save/Load article at the AI section of the wiki.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Who is online
Users browsing this forum: No registered users and 8 guests