2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-04-02 19:42:19 +02:00
|
|
|
-- `openmw.core` defines functions and types that are available in both local
|
|
|
|
-- and global scripts.
|
|
|
|
-- @module core
|
|
|
|
-- @usage local core = require('openmw.core')
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-07-25 15:36:25 +02:00
|
|
|
-- The revision of OpenMW Lua API. It is an integer that is incremented every time the API is changed.
|
|
|
|
-- @field [parent=#core] #number API_REVISION
|
2021-04-02 19:42:19 +02:00
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-08-04 19:14:24 +03:00
|
|
|
-- Terminates the game and quits to the OS. Should be used only for testing purposes.
|
|
|
|
-- @function [parent=#core] quit
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-04-02 19:42:19 +02:00
|
|
|
-- Send an event to global scripts.
|
|
|
|
-- @function [parent=#core] sendGlobalEvent
|
|
|
|
-- @param #string eventName
|
|
|
|
-- @param eventData
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-12-01 21:28:05 +01:00
|
|
|
-- Simulation time in seconds.
|
|
|
|
-- The number of simulation seconds passed in the game world since starting a new game.
|
|
|
|
-- @function [parent=#core] getSimulationTime
|
|
|
|
-- @return #number
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-12-01 21:28:05 +01:00
|
|
|
-- The scale of simulation time relative to real time.
|
|
|
|
-- @function [parent=#core] getSimulationTimeScale
|
|
|
|
-- @return #number
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-04-02 19:42:19 +02:00
|
|
|
-- Game time in seconds.
|
2021-12-01 21:28:05 +01:00
|
|
|
-- @function [parent=#core] getGameTime
|
2021-04-02 19:42:19 +02:00
|
|
|
-- @return #number
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-12-01 21:28:05 +01:00
|
|
|
-- The scale of game time relative to simulation time.
|
|
|
|
-- @function [parent=#core] getGameTimeScale
|
2021-04-02 19:42:19 +02:00
|
|
|
-- @return #number
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-12-14 00:51:18 +01:00
|
|
|
-- Whether the world is paused (onUpdate doesn't work when the world is paused).
|
|
|
|
-- @function [parent=#core] isWorldPaused
|
|
|
|
-- @return #boolean
|
|
|
|
|
2022-05-18 12:11:36 +02:00
|
|
|
---
|
|
|
|
-- Real time in seconds; starting point is not fixed (can be time since last reboot), use only for measuring intervals. For Unix time use `os.time()`.
|
|
|
|
-- @function [parent=#core] getRealTime
|
|
|
|
-- @return #number
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-12-14 00:39:01 +01:00
|
|
|
-- Get a GMST setting from content files.
|
|
|
|
-- @function [parent=#core] getGMST
|
|
|
|
-- @param #string setting Setting name
|
|
|
|
-- @return #any
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2022-04-10 07:57:02 +00:00
|
|
|
-- Return l10n formatting function for the given context.
|
2022-04-12 13:09:53 -04:00
|
|
|
-- Localisation files (containing the message names and translations) should be stored in
|
|
|
|
-- VFS as files of the form `l10n/<ContextName>/<Locale>.yaml`.
|
2022-04-10 07:57:02 +00:00
|
|
|
--
|
2022-04-12 13:09:53 -04:00
|
|
|
-- See [Localisation](../modding/localisation.html) for details of the localisation file structure.
|
2022-04-10 07:57:02 +00:00
|
|
|
--
|
2022-04-12 14:11:55 -04:00
|
|
|
-- When calling the l10n formatting function, if no localisation can be found for any of the requested locales then
|
|
|
|
-- the message key will be returned instead (and formatted, if possible).
|
|
|
|
-- This makes it possible to use the source strings as message identifiers.
|
|
|
|
--
|
|
|
|
-- If you do not use the source string as a message identifier you should instead make certain to include
|
|
|
|
-- a fallback locale with a complete set of messages.
|
|
|
|
--
|
2022-04-10 07:57:02 +00:00
|
|
|
-- @function [parent=#core] l10n
|
|
|
|
-- @param #string context l10n context; recommended to use the name of the mod.
|
2022-04-12 13:09:53 -04:00
|
|
|
-- This must match the <ContextName> directory in the VFS which stores the localisation files.
|
2022-04-10 07:57:02 +00:00
|
|
|
-- @param #string fallbackLocale The source locale containing the default messages
|
2022-04-12 14:11:55 -04:00
|
|
|
-- If omitted defaults to "en".
|
2021-12-26 21:49:20 +01:00
|
|
|
-- @return #function
|
|
|
|
-- @usage
|
2022-04-10 07:57:02 +00:00
|
|
|
-- # DataFiles/l10n/MyMod/en.yaml
|
|
|
|
-- good_morning: 'Good morning.'
|
|
|
|
--
|
2022-04-12 13:09:53 -04:00
|
|
|
-- you_have_arrows: |-
|
|
|
|
-- {count, plural,
|
2022-04-10 07:57:02 +00:00
|
|
|
-- one {You have one arrow.}
|
|
|
|
-- other {You have {count} arrows.}
|
|
|
|
-- }
|
2021-12-26 21:49:20 +01:00
|
|
|
-- @usage
|
2022-04-10 07:57:02 +00:00
|
|
|
-- # DataFiles/l10n/MyMod/de.yaml
|
|
|
|
-- good_morning: "Guten Morgen."
|
2022-04-12 13:09:53 -04:00
|
|
|
-- you_have_arrows: |-
|
|
|
|
-- {count, plural,
|
2022-04-10 07:57:02 +00:00
|
|
|
-- one {Du hast ein Pfeil.}
|
|
|
|
-- other {Du hast {count} Pfeile.}
|
|
|
|
-- }
|
|
|
|
-- "Hello {name}!": "Hallo {name}!"
|
2021-12-26 21:49:20 +01:00
|
|
|
-- @usage
|
2022-04-10 07:57:02 +00:00
|
|
|
-- -- Usage in Lua
|
|
|
|
-- local myMsg = core.l10n('MyMod', 'en')
|
2021-12-26 21:49:20 +01:00
|
|
|
-- print( myMsg('good_morning') )
|
|
|
|
-- print( myMsg('you_have_arrows', {count=5}) )
|
2022-04-10 07:57:02 +00:00
|
|
|
-- print( myMsg('Hello {name}!', {name='World'}) )
|
2021-12-26 21:49:20 +01:00
|
|
|
|
2021-04-02 19:42:19 +02:00
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-04-02 19:42:19 +02:00
|
|
|
-- Any object that exists in the game world and has a specific location.
|
|
|
|
-- Player, actors, items, and statics are game objects.
|
|
|
|
-- @type GameObject
|
2022-02-01 00:32:26 +01:00
|
|
|
-- @field openmw.util#Vector3 position Object position.
|
|
|
|
-- @field openmw.util#Vector3 rotation Object rotation (ZXY order).
|
|
|
|
-- @field #Cell cell The cell where the object currently is. During loading a game and for objects in an inventory or a container `cell` is nil.
|
2022-03-13 00:38:36 +01:00
|
|
|
-- @field #table type Type of the object (one of the tables from the package @{openmw.types#types}).
|
|
|
|
-- @field #number count Count (makes sense if stored in a container).
|
2022-02-01 00:32:26 +01:00
|
|
|
-- @field #string recordId Record ID.
|
2021-04-02 19:42:19 +02:00
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2022-03-13 00:38:36 +01:00
|
|
|
-- Does the object still exist and is available.
|
2021-04-02 19:42:19 +02:00
|
|
|
-- Returns true if the object exists and loaded, and false otherwise. If false, then every
|
|
|
|
-- access to the object will raise an error.
|
|
|
|
-- @function [parent=#GameObject] isValid
|
|
|
|
-- @param self
|
|
|
|
-- @return #boolean
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-04-02 19:42:19 +02:00
|
|
|
-- Send local event to the object.
|
|
|
|
-- @function [parent=#GameObject] sendEvent
|
|
|
|
-- @param self
|
|
|
|
-- @param #string eventName
|
|
|
|
-- @param eventData
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2022-02-01 23:42:56 +00:00
|
|
|
-- Activate the object.
|
|
|
|
-- @function [parent=#GameObject] activateBy
|
|
|
|
-- @param self
|
|
|
|
-- @param #GameObject actor The actor who activates the object
|
|
|
|
-- @usage local self = require('openmw.self')
|
|
|
|
-- object:activateBy(self)
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-04-02 19:42:19 +02:00
|
|
|
-- Add new local script to the object.
|
2021-10-10 22:43:47 +02:00
|
|
|
-- Can be called only from a global script. Script should be specified in a content
|
2022-03-13 00:38:36 +01:00
|
|
|
-- file (omwgame/omwaddon/omwscripts) with a CUSTOM flag. Scripts can not be attached to Statics.
|
2021-04-02 19:42:19 +02:00
|
|
|
-- @function [parent=#GameObject] addScript
|
|
|
|
-- @param self
|
2021-10-10 22:43:47 +02:00
|
|
|
-- @param #string scriptPath Path to the script in OpenMW virtual filesystem.
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-10-10 22:43:47 +02:00
|
|
|
-- Whether a script with given path is attached to this object.
|
|
|
|
-- Can be called only from a global script.
|
|
|
|
-- @function [parent=#GameObject] hasScript
|
|
|
|
-- @param self
|
|
|
|
-- @param #string scriptPath Path to the script in OpenMW virtual filesystem.
|
|
|
|
-- @return #boolean
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-10-10 22:43:47 +02:00
|
|
|
-- Removes script that was attached by `addScript`
|
|
|
|
-- Can be called only from a global script.
|
|
|
|
-- @function [parent=#GameObject] removeScript
|
|
|
|
-- @param self
|
|
|
|
-- @param #string scriptPath Path to the script in OpenMW virtual filesystem.
|
2021-04-02 19:42:19 +02:00
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-04-02 19:42:19 +02:00
|
|
|
-- Moves object to given cell and position.
|
|
|
|
-- The effect is not immediate: the position will be updated only in the next
|
|
|
|
-- frame. Can be called only from a global script.
|
|
|
|
-- @function [parent=#GameObject] teleport
|
|
|
|
-- @param self
|
|
|
|
-- @param #string cellName Name of the cell to teleport into. For exteriors can be empty.
|
|
|
|
-- @param openmw.util#Vector3 position New position
|
|
|
|
-- @param openmw.util#Vector3 rotation New rotation. Optional argument. If missed, then the current rotation is used.
|
|
|
|
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2022-02-21 20:43:27 +00:00
|
|
|
-- List of GameObjects. Implements [iterables#List](iterables.html#List) of #GameObject
|
2021-04-02 19:42:19 +02:00
|
|
|
-- @type ObjectList
|
2022-02-21 20:43:27 +00:00
|
|
|
-- @list <#GameObject>
|
2021-04-02 19:42:19 +02:00
|
|
|
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-04-02 19:42:19 +02:00
|
|
|
-- A cell of the game world.
|
|
|
|
-- @type Cell
|
2022-02-01 00:32:26 +01:00
|
|
|
-- @field #string name Name of the cell (can be empty string).
|
|
|
|
-- @field #string region Region of the cell.
|
|
|
|
-- @field #boolean isExterior Is it exterior or interior.
|
|
|
|
-- @field #number gridX Index of the cell by X (only for exteriors).
|
|
|
|
-- @field #number gridY Index of the cell by Y (only for exteriors).
|
|
|
|
-- @field #boolean hasWater True if the cell contains water.
|
2021-04-02 19:42:19 +02:00
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-04-02 19:42:19 +02:00
|
|
|
-- Returns true either if the cell contains the object or if the cell is an exterior and the object is also in an exterior.
|
|
|
|
-- @function [parent=#Cell] isInSameSpace
|
|
|
|
-- @param self
|
|
|
|
-- @param #GameObject object
|
|
|
|
-- @return #boolean
|
|
|
|
-- @usage
|
|
|
|
-- if obj1.cell:isInSameSpace(obj2) then
|
|
|
|
-- dist = (obj1.position - obj2.position):length()
|
|
|
|
-- else
|
|
|
|
-- -- the distance can't be calculated because the coordinates are in different spaces
|
|
|
|
-- end
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2022-03-13 00:38:36 +01:00
|
|
|
-- Get all objects of given type from the cell.
|
|
|
|
-- @function [parent=#Cell] getAll
|
2021-04-02 19:42:19 +02:00
|
|
|
-- @param self
|
2022-03-13 00:38:36 +01:00
|
|
|
-- @param type (optional) object type (see @{openmw.types#types})
|
2021-04-02 19:42:19 +02:00
|
|
|
-- @return #ObjectList
|
2022-03-13 00:38:36 +01:00
|
|
|
-- @usage
|
|
|
|
-- local type = require('openmw.types')
|
|
|
|
-- local all = cell:getAll()
|
|
|
|
-- local weapons = cell:getAll(types.Weapon)
|
2021-04-02 19:42:19 +02:00
|
|
|
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-04-02 19:42:19 +02:00
|
|
|
-- Inventory of a player/NPC or a content of a container.
|
|
|
|
-- @type Inventory
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2021-04-02 19:42:19 +02:00
|
|
|
-- The number of items with given recordId.
|
|
|
|
-- @function [parent=#Inventory] countOf
|
|
|
|
-- @param self
|
|
|
|
-- @param #string recordId
|
|
|
|
-- @return #number
|
|
|
|
|
2022-02-23 22:08:50 +01:00
|
|
|
---
|
2022-02-01 00:32:26 +01:00
|
|
|
-- Get all items of given type from the inventory.
|
2021-04-02 19:42:19 +02:00
|
|
|
-- @function [parent=#Inventory] getAll
|
|
|
|
-- @param self
|
2022-03-13 00:38:36 +01:00
|
|
|
-- @param type (optional) items type (see @{openmw.types#types})
|
2021-04-02 19:42:19 +02:00
|
|
|
-- @return #ObjectList
|
2022-03-13 00:38:36 +01:00
|
|
|
-- @usage
|
|
|
|
-- local type = require('openmw.types')
|
|
|
|
-- local all = inventory:getAll()
|
|
|
|
-- local weapons = inventory:getAll(types.Weapon)
|
2021-04-02 19:42:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|