Engine handlers reference¶
Engine handler is a function defined by a script, that can be called by the engine.
Can be defined by any script
Called once when the script is created (not loaded). InitData can be
assigned to a script in openmw-cs (not yet implemented).
Called every frame if the game is not paused. dt is
the simulation time from the last update in seconds.
|onSave() -> savedData||
Called when the game is saving. May be called in inactive state,
so it shouldn’t use openmw.nearby.
Called on loading with the data previosly returned by
the same as in
If a script did not exist when a game was saved onLoad will not be
Called if the current script has an interface and overrides an interface
Only for global scripts
|onNewGame()||New game is started.|
|onPlayerAdded(player)||Player added to the game world. The argument is a Game object.|
|onObjectActive(object)||Object becomes active.|
|onActorActive(actor)||Actor (NPC or Creature) becomes active.|
Item (Weapon, Potion, …) becomes active in a cell.
Does not apply to items in inventories or containers.
|onActivate(object, actor)||Object is activated by an actor.|
Only for local scripts
Called when the object becomes active
(either a player came to this cell again, or a save was loaded).
Object became inactive. Since it is inactive the handler
can not access anything nearby, but it is possible to send
an event to global scripts.
Called on an object when an actor activates it. Note that picking
up an item is also an activation and works this way: (1) a copy of
the item is placed to the actor’s inventory, (2) count of
the original item is set to zero, (3) and only then onActivated is
called on the original item, so self.count is already zero.
Called on an actor when they consume an item (e.g. a potion).
Similarly to onActivated, the item has already been removed
from the actor’s inventory, and the count was set to zero.
Only for local scripts attached to a player
Called every frame (even if the game is paused) right after
processing user input. Use it only for latency-critical stuff
and for UI that should work on pause.
dt is simulation time delta (0 when on pause).
Key is pressed.
Key is released.
A button on a game controller is pressed.
A button on a game controller is released.
Game control is pressed.
A finger pressed on a touch device.
A finger released a touch device.
A finger moved on a touch device.
mode, command, selectedObject)
User entered command in in-game console. Called if either
mode is not default or command starts with prefix lua.