1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-31 06:45:35 +00:00

Add better explanation of the onLoad engine handler.

This commit is contained in:
Petr Mikheev 2022-01-29 00:52:08 +00:00
parent 53f2dfd1c0
commit 81af493412

View file

@ -246,11 +246,14 @@ See :ref:`Engine handlers reference`.
onSave and onLoad onSave and onLoad
================= =================
When a game is saved or loaded, the engine calls the engine handlers `onSave` or `onLoad` for every script. When a game is saved or loaded, the engine calls the engine handlers `onSave` or `onLoad` to save or load each script.
The value that `onSave` returns will be passed to `onLoad` when the game is loaded. The value that `onSave` returns will be passed to `onLoad` when the game is loaded.
It is the only way to save the internal state of a script. All other script variables will be lost after closing the game. It is the only way to save the internal state of a script. All other script variables will be lost after closing the game.
The saved state must be :ref:`serializable <Serializable data>`. The saved state must be :ref:`serializable <Serializable data>`.
Note that `onLoad` means loading a script rather than loading a game. During loading a game `onLoad` works only for the scripts that were already existed when the game was saved (i.e. present in the save file).
If a completely new script was started (for example if it is a script of a newly installed mod) then the `onInit` handler is used even if it happened when loading a saved game.
`onSave` and `onLoad` can be called even for objects in inactive state, so it shouldn't use `openmw.nearby`. `onSave` and `onLoad` can be called even for objects in inactive state, so it shouldn't use `openmw.nearby`.
An example: An example: