2022-01-23 19:49:42 +00:00
Built-in events
===============
2023-08-27 18:43:12 +00:00
.. include :: version.rst
2023-07-09 06:42:09 +00:00
Actor events
------------
2023-08-18 20:55:43 +00:00
**StartAIPackage, RemoveAIPackages**
2022-01-23 19:49:42 +00:00
Any script can send to any actor (except player, for player will be ignored) events `` StartAIPackage `` and `` RemoveAIPackages `` .
The effect is equivalent to calling `` interfaces.AI.startPackage `` or `` interfaces.AI.removePackages `` in a local script on this actor.
Examples:
.. code-block :: Lua
actor:sendEvent('StartAIPackage', {type='Combat', target=self.object})
actor:sendEvent('RemoveAIPackages', 'Pursue')
2023-08-18 20:55:43 +00:00
**UseItem**
Any script can send global event `` UseItem `` with arguments `` object `` and `` actor `` .
The actor will use (e.g. equip or consume) the object. The object should be in the actor's inventory.
Example:
.. code-block :: Lua
core.sendGlobalEvent('UseItem', {object = potion, actor = player})
2023-07-09 06:42:09 +00:00
UI events
---------
2023-08-20 15:12:22 +00:00
Every time UI mode is changed built-in scripts send to player the event `` UiModeChanged `` with arguments `` oldMode, ` ` newMode `` (same as `` I.UI.getMode() `` )
2023-07-09 06:42:09 +00:00
and `` arg `` (for example in the mode `` Book `` the argument is the book the player is reading).
.. code-block :: Lua
eventHandlers = {
UiModeChanged = function(data)
2023-08-20 15:12:22 +00:00
print('UiModeChanged from', data.oldMode , 'to', data.newMode, '('..tostring(data.arg)..')')
2023-07-09 06:42:09 +00:00
end
}
2023-09-03 00:45:18 +00:00
World events
------------
Global events that just call the corresponding function in `openmw.world` .
.. code-block :: Lua
-- world.pause(tag)
core.sendGlobalEvent('Pause', tag)
-- world.unpause(tag)
core.sendGlobalEvent('Unpause', tag)
-- world.setGameTimeScale(scale)
core.sendGlobalEvent('SetGameTimeScale', scale)
-- world.setSimulationTimeScale(scale)
core.sendGlobalEvent('SetSimulationTimeScale', scale)