Package openmw.worldΒΆ
openmw.world
is an interface to the game world for global scripts.
Can not be used from local scripts.
Usage:
local world = require('openmw.world')
Type world
world.activeActors |
List of currently active actors. |
world.cells |
List of all cells |
world.createObject(recordId, count) |
Create a new instance of the given record. |
world.createRecord(record) |
Creates a custom record in the world database. |
world.getCellByName(cellName) |
Loads a named cell |
world.getExteriorCell(gridX, gridY, cellOrName) |
Loads an exterior cell by grid indices |
world.getGameTime() |
Game time in seconds. |
world.getGameTimeScale() |
The scale of game time relative to simulation time. |
world.getSimulationTime() |
Simulation time in seconds. |
world.getSimulationTimeScale() |
The scale of simulation time relative to real time. |
world.isWorldPaused() |
Whether the world is paused (onUpdate doesn't work when the world is paused). |
world.setGameTimeScale(ratio) |
Set the ratio of game time speed to simulation time speed. |
world.setSimulationTimeScale(scale) |
Set the simulation time scale. |
Type world
Field(s)
- openmw.core#ObjectList world.activeActors
-
List of currently active actors.
- #list<openmw.core#Cell> world.cells
-
List of all cells
Usage:
for i, cell in ipairs(world.cells) do print(cell) end
- world.createObject(recordId, count)
-
Create a new instance of the given record.
After creation the object is in the disabled state. Use :teleport to place to the world or :moveInto to put it into a container or an inventory.
Parameters
-
#string recordId
: Record ID in lowercase -
#number count
: (optional, 1 by default) The number of objects in stack
Return value
Usages:
-- put 100 gold on the ground at the position of `actor` money = world.createObject('gold_001', 100) money:teleport(actor.cell.name, actor.position)
-- put 50 gold into the actor's inventory money = world.createObject('gold_001', 50) money:moveInto(types.Actor.inventory(actor))
-
- world.createRecord(record)
-
Creates a custom record in the world database.
Eventually meant to support all records, but the current set of supported types is limited to: * openmw.types#PotionRecord, * openmw.types#ArmorRecord, * openmw.types#BookRecord, * openmw.types#MiscellaneousRecord, * openmw.types#ActivatorRecord
Parameter
-
#any record
: A record to be registered in the database. Must be one of the supported types.
Return value
#any: A new record added to the database. The type is the same as the input's.
-
- world.getCellByName(cellName)
-
Loads a named cell
Parameter
-
#string cellName
:
Return value
-
- world.getExteriorCell(gridX, gridY, cellOrName)
-
Loads an exterior cell by grid indices
Parameters
-
#number gridX
: -
#number gridY
: -
#any cellOrName
: (optional) other cell or cell name in the same exterior world space
Return value
-
- world.getGameTime()
-
Game time in seconds.
Return value
#number:
- world.getGameTimeScale()
-
The scale of game time relative to simulation time.
Return value
#number:
- world.getSimulationTime()
-
Simulation time in seconds.
The number of simulation seconds passed in the game world since starting a new game.
Return value
#number:
- world.getSimulationTimeScale()
-
The scale of simulation time relative to real time.
Return value
#number:
- world.isWorldPaused()
-
Whether the world is paused (onUpdate doesn't work when the world is paused).
Return value
#boolean:
- world.setGameTimeScale(ratio)
-
Set the ratio of game time speed to simulation time speed.
Parameter
-
#number ratio
:
-
- world.setSimulationTimeScale(scale)
-
Set the simulation time scale.
Parameter
-
#number scale
:
-