mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 17:39:42 +00:00
Add better explanation of the onLoad
engine handler.
This commit is contained in:
parent
e46905450e
commit
ec4adcc5a2
2 changed files with 7 additions and 1 deletions
|
@ -19,6 +19,9 @@ Engine handler is a function defined by a script, that can be called by the engi
|
||||||
| onLoad(savedData, initData) | | Called on loading with the data previosly returned by |
|
| onLoad(savedData, initData) | | Called on loading with the data previosly returned by |
|
||||||
| | | onSave. During loading the object is always inactive. initData is |
|
| | | onSave. During loading the object is always inactive. initData is |
|
||||||
| | | the same as in onInit. |
|
| | | the same as in onInit. |
|
||||||
|
| | | Note that onLoad means loading a script rather than loading a game.|
|
||||||
|
| | | If a script did not exist when a game was saved onLoad will not be |
|
||||||
|
| | | called, but onInit will. |
|
||||||
+----------------------------------+----------------------------------------------------------------------+
|
+----------------------------------+----------------------------------------------------------------------+
|
||||||
| onInterfaceOverride(base) | | Called if the current script has an interface and overrides an |
|
| onInterfaceOverride(base) | | Called if the current script has an interface and overrides an |
|
||||||
| | | interface (``base``) of another script. |
|
| | | interface (``base``) of another script. |
|
||||||
|
|
|
@ -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.
|
||||||
|
If a script did not exist when a game was saved then `onLoad` will not be called, but `onInit` will.
|
||||||
|
|
||||||
`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:
|
||||||
|
|
Loading…
Reference in a new issue