Package openmw.coreΒΆ
openmw.core
defines functions and types that are available in both local
and global scripts.
Usage:
local core = require('openmw.core')
Type core
core.API_REVISION |
The revision of OpenMW Lua API. |
core.contentFiles |
#ContentFiles: functions working with the list of currently loaded content files. |
core.factions |
A read-only list of all #FactionRecords in the world database. |
core.getFormId(contentFile, index) |
Construct FormId string from content file name and the index in the file. |
core.getGMST(setting) |
Get a GMST setting from content files. |
core.getGameTime() |
Game time in seconds. |
core.getGameTimeScale() |
The scale of game time relative to simulation time. |
core.getRealTime() |
Real time in seconds; starting point is not fixed (can be time since last reboot), use only for measuring intervals. |
core.getSimulationTime() |
Simulation time in seconds. |
core.getSimulationTimeScale() |
The scale of simulation time relative to real time. |
core.isWorldPaused() |
Whether the world is paused (onUpdate doesn't work when the world is paused). |
core.l10n(context, fallbackLocale) |
Return l10n formatting function for the given context. |
core.magic |
#Magic: spells and spell effects |
core.quit() |
Terminates the game and quits to the OS. |
core.sendGlobalEvent(eventName, eventData) |
Send an event to global scripts. |
core.sound |
#Sound: Sounds and Speech |
core.stats |
#Stats: stats |
Type ActiveEffect
ActiveEffect.affectedAttribute |
Optional attribute ID |
ActiveEffect.affectedSkill |
Optional skill ID |
ActiveEffect.id |
Effect id string |
ActiveEffect.magnitude |
current magnitude of the effect. Will be set to 0 when effect is removed or expires. |
ActiveEffect.magnitudeBase | |
ActiveEffect.magnitudeModifier | |
ActiveEffect.name |
Localized name of the effect |
Type ActiveSpell
ActiveSpell.caster |
The caster object, or nil if the spell has no defined caster |
ActiveSpell.effects |
The active effects (#ActiveSpellEffect) of this spell. |
ActiveSpell.id |
Record id of the spell or item used to cast the spell |
ActiveSpell.item |
The enchanted item used to cast the spell, or nil if the spell was not cast from an enchanted item. Note that if the spell was cast for a single-use enchantment such as a scroll, this will be nil. |
ActiveSpell.name |
The spell or item display name |
Type ActiveSpellEffect
ActiveSpellEffect.affectedAttribute |
Optional attribute ID |
ActiveSpellEffect.affectedSkill |
Optional skill ID |
ActiveSpellEffect.duration |
Total duration in seconds of this spell effect, should not be confused with remaining duration. Or nil if the effect is not temporary. |
ActiveSpellEffect.durationLeft |
Remaining duration in seconds of this spell effect, or nil if the effect is not temporary. |
ActiveSpellEffect.id |
Magic effect id |
ActiveSpellEffect.magnitudeThisFrame |
The magnitude of the effect in the current frame. This will be a new random number between minMagnitude and maxMagnitude every frame. Or nil if the effect has no magnitude. |
ActiveSpellEffect.maxMagnitude |
The maximum magnitude of this effect, or nil if the effect has no magnitude. |
ActiveSpellEffect.minMagnitude |
The minimum magnitude of this effect, or nil if the effect has no magnitude. |
ActiveSpellEffect.name |
Localized name of the effect |
Type Attribute
Attribute.record(recordId) |
Returns a read-only #AttributeRecord |
Attribute.records |
A read-only list of all #AttributeRecords in the world database. |
Type AttributeRecord
AttributeRecord.description |
Human-readable description |
AttributeRecord.icon |
VFS path to the icon |
AttributeRecord.id |
Record id |
AttributeRecord.name |
Human-readable name |
Type Cell
Cell:getAll(type) |
Get all objects of given type from the cell; Only available from global scripts. |
Cell.gridX |
Index of the cell by X (only for exteriors). |
Cell.gridY |
Index of the cell by Y (only for exteriors). |
Cell.hasSky |
True if in this cell sky should be rendered. |
Cell:hasTag(tag) |
Returns true if the cell has given tag. |
Cell.hasWater |
True if the cell contains water. |
Cell.isExterior |
Whether the cell is an exterior cell. "Exterior" means grid of cells where the player can seamless walk from one cell to another without teleports. QuasiExterior (interior with sky) is not an exterior. |
Cell:isInSameSpace(object) |
Returns true either if the cell contains the object or if the cell is an exterior and the object is also in an exterior. |
Cell.isQuasiExterior |
(DEPRECATED, use |
Cell.name |
Name of the cell (can be empty string). |
Cell.region |
Region of the cell. |
Cell.worldSpaceId |
Id of the world space. |
Type ContentFiles
ContentFiles.has(contentFile) |
Check if the content file with given name present in the load order. |
ContentFiles.indexOf(contentFile) |
Return the index of a specific content file in the load order (or |
ContentFiles.list |
The current load order (list of content file names). |
Type Enchantment
Enchantment.autocalcFlag |
If set, the casting cost should be computer rather than reading the cost field |
Enchantment.charge |
Charge capacity. Should not be confused with current charge. |
Enchantment.cost | |
Enchantment.effects |
The effects (#MagicEffectWithParams) of the enchantment |
Enchantment.id |
Enchantment id |
Enchantment.type |
Type EnchantmentType
EnchantmentType.CastOnStrike |
Enchantment is cast on strike, if there is enough charge. |
EnchantmentType.CastOnUse |
Enchantment is cast when used, if there is enough charge. |
EnchantmentType.CastOnce |
Enchantment can be cast once, destroying the enchanted item. |
EnchantmentType.ConstantEffect |
Enchantment is always active when equipped. |
Type FactionRank
FactionRank.attributeValues |
Attributes values required to get this rank. |
FactionRank.factionReaction |
Reaction of faction members if player is in this faction. |
FactionRank.favouredSkillValue |
Secondary skill value required to get this rank. |
FactionRank.name |
Faction name Rank display name |
FactionRank.primarySkillValue |
Primary skill value required to get this rank. |
Type FactionRecord
FactionRecord.attributes |
A read-only list containing IDs of attributes to advance ranks in the faction. |
FactionRecord.id |
Faction id |
FactionRecord.name |
Faction name |
FactionRecord.ranks |
A read-only list containing data for all ranks in the faction, in order. |
FactionRecord.reactions |
A read-only map containing reactions of other factions to this faction. |
FactionRecord.skills |
A read-only list containing IDs of skills to advance ranks in the faction. |
Type GameObject
GameObject:activateBy(actor) |
Activate the object. |
GameObject:addScript(scriptPath, initData) |
Add new local script to the object. |
GameObject.cell |
The cell where the object currently is. During loading a game and for objects in an inventory or a container |
GameObject.contentFile |
Lower cased file name of the content file that defines this object; nil for dynamically created objects. |
GameObject.count |
Count (>1 means a stack of objects). |
GameObject.enabled |
Whether the object is enabled or disabled. Global scripts can set the value. Items in containers or inventories can't be disabled. |
GameObject:getBoundingBox() |
The axis aligned bounding box in local coordinates. |
GameObject.globalVariable |
Global Variable associated with this object(read only). |
GameObject:hasScript(scriptPath) |
Whether a script with given path is attached to this object. |
GameObject.id |
A unique id of this object (not record id), can be used as a key in a table. |
GameObject:isValid() |
Does the object still exist and is available. |
GameObject:moveInto(dest) |
Moves object into a container or an inventory. |
GameObject.ownerFactionId |
Faction who owns the object (nil if missing). Global and self scripts can set the value. |
GameObject.ownerFactionRank |
Rank required to be allowed to pick up the object ( |
GameObject.ownerRecordId |
NPC who owns the object (nil if missing). Global and self scripts can set the value. |
GameObject.parentContainer |
Container or actor that contains (or has in inventory) this object. It is nil if the object is in a cell. |
GameObject.position |
Object position. |
GameObject.recordId |
Returns record ID of the object in lowercase. |
GameObject:remove(count) |
Removes an object or reduces a stack of objects. |
GameObject:removeScript(scriptPath) |
Removes script that was attached by |
GameObject.rotation |
Object rotation. |
GameObject.scale |
Object scale. |
GameObject:sendEvent(eventName, eventData) |
Send local event to the object. |
GameObject:setScale(scale) |
Sets the object's scale. |
GameObject:split(count) |
Splits a stack of items. |
GameObject.startingPosition |
The object original position |
GameObject.startingRotation |
The object original rotation |
GameObject:teleport(cellOrName, position, options) |
Moves object to given cell and position. |
GameObject.type |
Type of the object (one of the tables from the package openmw.types#types). |
Type Inventory
Inventory:countOf(recordId) |
The number of items with given recordId. |
Inventory:find(recordId) |
Get first item with given recordId from the inventory. |
Inventory:findAll(recordId) |
Get all items with given recordId from the inventory. |
Inventory:getAll(type) |
Get all items of given type from the inventory. |
Inventory:isResolved() |
Checks if the inventory has a resolved item list. |
Inventory:resolve() |
Will resolve the inventory, filling it with levelled items if applicable, making its contents permanent. |
Type Magic
Magic.EFFECT_TYPE |
Possible #MagicEffectId values |
Magic.ENCHANTMENT_TYPE |
Possible #EnchantmentType values |
Magic.RANGE |
Possible #SpellRange values |
Magic.SPELL_TYPE |
Possible #SpellType values |
Magic.effects |
Map from #MagicEffectId to #MagicEffect |
Magic.enchantments |
List of all #Enchantments. |
Magic.spells |
List of all #Spells. |
Type MagicEffect
MagicEffect.baseCost | |
MagicEffect.color | |
MagicEffect.harmful | |
MagicEffect.icon |
Effect Icon Path |
MagicEffect.id |
Effect ID |
MagicEffect.name |
Localized name of the effect |
MagicEffect.school |
Skill ID that is this effect's school |
Type MagicEffectId
Type MagicEffectWithParams
Type Skill
Skill.record(recordId) |
Returns a read-only #SkillRecord |
Skill.records |
A read-only list of all #SkillRecords in the world database. |
Type SkillRecord
SkillRecord.attribute |
The id of the skill's governing attribute |
SkillRecord.description |
Human-readable description |
SkillRecord.icon |
VFS path to the icon |
SkillRecord.id |
Record id |
SkillRecord.name |
Human-readable name |
SkillRecord.school |
Optional magic school |
SkillRecord.specialization |
Skill specialization. Either combat, magic, or stealth. |
Type Sound
Sound.isEnabled() |
Checks if sound system is enabled (any functions to play sounds are no-ops when it is disabled). |
Sound.isSayActive(object) |
Check if animated voiceover is playing |
Sound.isSoundFilePlaying(fileName, object) |
Check if sound file is playing on given object |
Sound.isSoundPlaying(soundId, object) |
Check if sound is playing on given object |
Sound.playSound3d(soundId, object, options) |
Play a 3D sound, attached to object |
Sound.playSoundFile3d(fileName, object, options) |
Play a 3D sound file, attached to object |
Sound.say(fileName, object, text) |
Play an animated voiceover. |
Sound.sounds |
List of all #SoundRecords. |
Sound.stopSay(fileName, object) |
Stop animated voiceover |
Sound.stopSound3d(soundId, object) |
Stop a 3D sound, attached to object |
Sound.stopSoundFile3d(fileName, object) |
Stop a 3D sound file, attached to object |
Type SoundRecord
SoundRecord.fileName |
Normalized path to sound file in VFS |
SoundRecord.id |
Sound id |
SoundRecord.maxRange |
Raw maximal range value, from 0 to 255 |
SoundRecord.minRange |
Raw minimal range value, from 0 to 255 |
SoundRecord.volume |
Raw sound volume, from 0 to 255 |
Type Spell
Spell.cost | |
Spell.effects |
The effects (#MagicEffectWithParams) of the spell |
Spell.id |
Spell id |
Spell.name |
Spell name |
Spell.type |
Type SpellRange
SpellRange.Self |
Applied on self |
SpellRange.Target |
Ranged spell |
SpellRange.Touch |
On touch |
Type SpellType
SpellType.Ability |
Innate ability, always in effect |
SpellType.Blight |
Blight disease |
SpellType.Curse |
Curse |
SpellType.Disease |
Common disease |
SpellType.Power |
Power, can be used once a day |
SpellType.Spell |
Normal spell, must be cast and costs mana |
Type Stats
Stats.Attribute |
#Attribute functions |
Stats.Skill |
#Skill functions |
Type TeleportOptions
TeleportOptions.onGround |
If true, adjust destination position to the ground. |
TeleportOptions.rotation |
New rotation; if missing, then the current rotation is used. |
Type core
Field(s)
- #number core.API_REVISION
-
The revision of OpenMW Lua API.
It is an integer that is incremented every time the API is changed. See the actual value at the top of the page.
- #ContentFiles core.contentFiles
-
#ContentFiles: functions working with the list of currently loaded content files.
- #list<#FactionRecord> core.factions
-
A read-only list of all #FactionRecords in the world database.
- core.getFormId(contentFile, index)
-
Construct FormId string from content file name and the index in the file.
In ESM3 games (e.g. Morrowind) FormIds are used to reference game objects. In ESM4 games (e.g. Skyrim) FormIds are used both for game objects and as record ids.
Parameters
-
#string contentFile
: -
#number index
:
Return value
#string:
Usages:
if obj.recordId == core.getFormId('Skyrim.esm', 0x4d7da) then ... end
-- In ESM3 content files (e.g. Morrowind) ids are human-readable strings obj.ownerFactionId = 'blades' -- In ESM4 (e.g. Skyrim) ids should be constructed using `core.getFormId`: obj.ownerFactionId = core.getFormId('Skyrim.esm', 0x72834)
-- local scripts local obj = nearby.getObjectByFormId(core.getFormId('Morrowind.esm', 128964))
-- global scripts local obj = world.getObjectByFormId(core.getFormId('Morrowind.esm', 128964))
-
- core.getGMST(setting)
-
Get a GMST setting from content files.
Parameter
-
#string setting
: Setting name
Return value
#any:
-
- core.getGameTime()
-
Game time in seconds.
Return value
#number:
- core.getGameTimeScale()
-
The scale of game time relative to simulation time.
Return value
#number:
- core.getRealTime()
-
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()
.Return value
#number:
- core.getSimulationTime()
-
Simulation time in seconds.
The number of simulation seconds passed in the game world since starting a new game.
Return value
#number:
- core.getSimulationTimeScale()
-
The scale of simulation time relative to real time.
Return value
#number:
- core.isWorldPaused()
-
Whether the world is paused (onUpdate doesn't work when the world is paused).
Return value
#boolean:
- core.l10n(context, fallbackLocale)
-
Return l10n formatting function for the given context.
Localisation files (containing the message names and translations) should be stored in VFS as files of the form
l10n/<ContextName>/<Locale>.yaml
.See Localisation for details of the localisation file structure.
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.
Parameters
-
#string context
: l10n context; recommended to use the name of the mod.This must match the <ContextName> directory in the VFS which stores the localisation files.
-
#string fallbackLocale
: The source locale containing the default messagesIf omitted defaults to "en".
Return value
#function:
Usages:
# DataFiles/l10n/MyMod/en.yaml good_morning: 'Good morning.' you_have_arrows: |- {count, plural, one {You have one arrow.} other {You have {count} arrows.} }
# DataFiles/l10n/MyMod/de.yaml good_morning: "Guten Morgen." you_have_arrows: |- {count, plural, one {Du hast ein Pfeil.} other {Du hast {count} Pfeile.} } "Hello {name}!": "Hallo {name}!"
-- Usage in Lua local myMsg = core.l10n('MyMod', 'en') print( myMsg('good_morning') ) print( myMsg('you_have_arrows', {count=5}) ) print( myMsg('Hello {name}!', {name='World'}) )
-
- #Magic core.magic
-
#Magic: spells and spell effects
- core.quit()
-
Terminates the game and quits to the OS.
Should be used only for testing purposes.
- core.sendGlobalEvent(eventName, eventData)
-
Send an event to global scripts.
Parameters
-
#string eventName
: -
eventData
:
-
- #Sound core.sound
-
#Sound: Sounds and Speech
- #Stats core.stats
-
#Stats: stats
Type ActiveEffect
Field(s)
- #string ActiveEffect.affectedAttribute
-
Optional attribute ID
- #string ActiveEffect.affectedSkill
-
Optional skill ID
- #string ActiveEffect.id
-
Effect id string
- #number ActiveEffect.magnitude
-
current magnitude of the effect. Will be set to 0 when effect is removed or expires.
- #number ActiveEffect.magnitudeBase
- #number ActiveEffect.magnitudeModifier
- #string ActiveEffect.name
-
Localized name of the effect
Type ActiveSpell
Field(s)
- #GameObject ActiveSpell.caster
-
The caster object, or nil if the spell has no defined caster
- #list<#ActiveSpellEffect> ActiveSpell.effects
-
The active effects (#ActiveSpellEffect) of this spell.
- #string ActiveSpell.id
-
Record id of the spell or item used to cast the spell
- #GameObject ActiveSpell.item
-
The enchanted item used to cast the spell, or nil if the spell was not cast from an enchanted item. Note that if the spell was cast for a single-use enchantment such as a scroll, this will be nil.
- #string ActiveSpell.name
-
The spell or item display name
Type ActiveSpellEffect
Field(s)
- #string ActiveSpellEffect.affectedAttribute
-
Optional attribute ID
- #string ActiveSpellEffect.affectedSkill
-
Optional skill ID
- #number ActiveSpellEffect.duration
-
Total duration in seconds of this spell effect, should not be confused with remaining duration. Or nil if the effect is not temporary.
- #number ActiveSpellEffect.durationLeft
-
Remaining duration in seconds of this spell effect, or nil if the effect is not temporary.
- #string ActiveSpellEffect.id
-
Magic effect id
- #number ActiveSpellEffect.magnitudeThisFrame
-
The magnitude of the effect in the current frame. This will be a new random number between minMagnitude and maxMagnitude every frame. Or nil if the effect has no magnitude.
- #number ActiveSpellEffect.maxMagnitude
-
The maximum magnitude of this effect, or nil if the effect has no magnitude.
- #number ActiveSpellEffect.minMagnitude
-
The minimum magnitude of this effect, or nil if the effect has no magnitude.
- #string ActiveSpellEffect.name
-
Localized name of the effect
Type Attribute
core.stats.Attribute
Field(s)
- Attribute.record(recordId)
-
Returns a read-only #AttributeRecord
Parameter
-
#string recordId
:
Return value
-
- #list<#AttributeRecord> Attribute.records
-
A read-only list of all #AttributeRecords in the world database.
Type AttributeRecord
Field(s)
- #string AttributeRecord.description
-
Human-readable description
- #string AttributeRecord.icon
-
VFS path to the icon
- #string AttributeRecord.id
-
Record id
- #string AttributeRecord.name
-
Human-readable name
Type Cell
A cell of the game world.
Field(s)
- Cell:getAll(type)
-
Get all objects of given type from the cell; Only available from global scripts.
Parameter
-
type
: (optional) object type (see openmw.types#types)
Return value
Usage:
local type = require('openmw.types') local all = cell:getAll() local weapons = cell:getAll(types.Weapon)
-
- #number Cell.gridX
-
Index of the cell by X (only for exteriors).
- #number Cell.gridY
-
Index of the cell by Y (only for exteriors).
- #boolean Cell.hasSky
-
True if in this cell sky should be rendered.
- Cell:hasTag(tag)
-
Returns true if the cell has given tag.
Parameter
-
#string tag
: One of "QuasiExterior", "NoSleep".
Return value
#boolean:
-
- #boolean Cell.hasWater
-
True if the cell contains water.
- #boolean Cell.isExterior
-
Whether the cell is an exterior cell. "Exterior" means grid of cells where the player can seamless walk from one cell to another without teleports. QuasiExterior (interior with sky) is not an exterior.
- Cell:isInSameSpace(object)
-
Returns true either if the cell contains the object or if the cell is an exterior and the object is also in an exterior.
Parameter
-
#GameObject object
:
Return value
#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
-
- #boolean Cell.isQuasiExterior
-
(DEPRECATED, use
hasTag("QuasiExterior")
) Whether the cell is a quasi exterior (like interior but with the sky and the wheather).
- #string Cell.name
-
Name of the cell (can be empty string).
- #string Cell.region
-
Region of the cell.
- #string Cell.worldSpaceId
-
Id of the world space.
Type ContentFiles
Functions working with the list of currently loaded content files.
Field(s)
- ContentFiles.has(contentFile)
-
Check if the content file with given name present in the load order.
Parameter
-
#string contentFile
:
Return value
#boolean:
-
- ContentFiles.indexOf(contentFile)
-
Return the index of a specific content file in the load order (or
nil
if there is no such content file).Parameter
-
#string contentFile
:
Return value
#number:
-
- #list<#string> ContentFiles.list
-
The current load order (list of content file names).
Type Enchantment
Usage:
-- Getting the enchantment of an arbitrary item, if it has one
local function getRecord(item)
if item.type and item.type.record then
return item.type.record(item)
end
return nil
end
local function getEnchantment(item)
local record = getRecord(item)
if record and record.enchant then
return core.magic.enchantments[record.enchant]
end
return nil
end
Field(s)
- #number Enchantment.autocalcFlag
-
If set, the casting cost should be computer rather than reading the cost field
- #number Enchantment.charge
-
Charge capacity. Should not be confused with current charge.
- #number Enchantment.cost
- #list<#MagicEffectWithParams> Enchantment.effects
-
The effects (#MagicEffectWithParams) of the enchantment
- #string Enchantment.id
-
Enchantment id
- #number Enchantment.type
Type EnchantmentType
core.magic.ENCHANTMENT_TYPE
Field(s)
- #number EnchantmentType.CastOnStrike
-
Enchantment is cast on strike, if there is enough charge.
- #number EnchantmentType.CastOnUse
-
Enchantment is cast when used, if there is enough charge.
- #number EnchantmentType.CastOnce
-
Enchantment can be cast once, destroying the enchanted item.
- #number EnchantmentType.ConstantEffect
-
Enchantment is always active when equipped.
Type FactionRank
Faction rank data record
Field(s)
- #list<#number> FactionRank.attributeValues
-
Attributes values required to get this rank.
- #number FactionRank.factionReaction
-
Reaction of faction members if player is in this faction.
- #number FactionRank.favouredSkillValue
-
Secondary skill value required to get this rank.
- #string FactionRank.name
-
Faction name Rank display name
- #number FactionRank.primarySkillValue
-
Primary skill value required to get this rank.
Type FactionRecord
Faction data record
Field(s)
- #list<#string> FactionRecord.attributes
-
A read-only list containing IDs of attributes to advance ranks in the faction.
- #string FactionRecord.id
-
Faction id
- #string FactionRecord.name
-
Faction name
- #list<#FactionRank> FactionRecord.ranks
-
A read-only list containing data for all ranks in the faction, in order.
- #map<#string,#number> FactionRecord.reactions
-
A read-only map containing reactions of other factions to this faction.
- #list<#string> FactionRecord.skills
-
A read-only list containing IDs of skills to advance ranks in the faction.
Type GameObject
Extends #userdata
Any object that exists in the game world and has a specific location.
Player, actors, items, and statics are game objects.
Field(s)
- GameObject:activateBy(actor)
-
Activate the object.
Parameter
-
#GameObject actor
: The actor who activates the object
Usage:
local self = require('openmw.self') object:activateBy(self)
-
- GameObject:addScript(scriptPath, initData)
-
Add new local script to the object.
Can be called only from a global script. Script should be specified in a content file (omwgame/omwaddon/omwscripts) with a CUSTOM flag. Scripts can not be attached to Statics.
Parameters
-
#string scriptPath
: Path to the script in OpenMW virtual filesystem. -
#table initData
: (optional) Initialization data to be passed to onInit. If missed then Lua initialization data from content files will be used (if exists for this script).
-
- #Cell GameObject.cell
-
The cell where the object currently is. During loading a game and for objects in an inventory or a container
cell
is nil.
- #string GameObject.contentFile
-
Lower cased file name of the content file that defines this object; nil for dynamically created objects.
- #number GameObject.count
-
Count (>1 means a stack of objects).
- #boolean GameObject.enabled
-
Whether the object is enabled or disabled. Global scripts can set the value. Items in containers or inventories can't be disabled.
- GameObject:getBoundingBox()
-
The axis aligned bounding box in local coordinates.
Return value
- #string GameObject.globalVariable
-
Global Variable associated with this object(read only).
- GameObject:hasScript(scriptPath)
-
Whether a script with given path is attached to this object.
Can be called only from a global script.
Parameter
-
#string scriptPath
: Path to the script in OpenMW virtual filesystem.
Return value
#boolean:
-
- #string GameObject.id
-
A unique id of this object (not record id), can be used as a key in a table.
- GameObject:isValid()
-
Does the object still exist and is available.
Returns true if the object exists and loaded, and false otherwise. If false, then every access to the object will raise an error.
Return value
#boolean:
- GameObject:moveInto(dest)
-
Moves object into a container or an inventory.
Enables if was disabled. Can be called only from a global script.
Parameter
-
#any dest
: #Inventory or #GameObject
Usages:
item:moveInto(types.Actor.inventory(actor))
item:moveInto(types.Container.content(container))
item:moveInto(container)
-
- #string GameObject.ownerFactionId
-
Faction who owns the object (nil if missing). Global and self scripts can set the value.
- #number GameObject.ownerFactionRank
-
Rank required to be allowed to pick up the object (
nil
if any rank is allowed). Global and self scripts can set the value.
- #string GameObject.ownerRecordId
-
NPC who owns the object (nil if missing). Global and self scripts can set the value.
- #GameObject GameObject.parentContainer
-
Container or actor that contains (or has in inventory) this object. It is nil if the object is in a cell.
- openmw.util#Vector3 GameObject.position
-
Object position.
- #string GameObject.recordId
-
Returns record ID of the object in lowercase.
- GameObject:remove(count)
-
Removes an object or reduces a stack of objects.
Can be called only from a global script.
Parameter
-
#number count
: (optional) the number of items to remove (if not specified then the whole stack)
-
- GameObject:removeScript(scriptPath)
-
Removes script that was attached by
addScript
Can be called only from a global script.Parameter
-
#string scriptPath
: Path to the script in OpenMW virtual filesystem.
-
- openmw.util#Transform GameObject.rotation
-
Object rotation.
- #number GameObject.scale
-
Object scale.
- GameObject:sendEvent(eventName, eventData)
-
Send local event to the object.
Parameters
-
#string eventName
: -
eventData
:
-
- GameObject:setScale(scale)
-
Sets the object's scale.
Can be called only from a global script.
Parameter
-
#number scale
: Scale desired in game.
-
- GameObject:split(count)
-
Splits a stack of items.
Original stack is reduced by
count
. Returns a new stack withcount
items. Can be called only from a global script.Parameter
-
#number count
: The number of items to return.
Usage:
-- take 50 coins from `money` and put to the container `cont` money:split(50):moveInto(types.Container.content(cont))
-
- openmw.util#Vector3 GameObject.startingPosition
-
The object original position
- openmw.util#Transform GameObject.startingRotation
-
The object original rotation
- GameObject:teleport(cellOrName, position, options)
-
Moves object to given cell and position.
Can be called only from a global script. The effect is not immediate: the position will be updated only in the next frame. Can be called only from a global script. Enables object if it was disabled. Can be used to move objects from an inventory or a container to the world.
Parameters
-
#any cellOrName
: A cell to define the destination worldspace; can be either #Cell, or cell name, or an empty string (empty string means the default exterior worldspace). If the worldspace has multiple cells (i.e. an exterior), the destination cell is calculated usingposition
. -
openmw.util#Vector3 position
: New position. -
#TeleportOptions options
: (optional) Either table #TeleportOptions or openmw.util#Transform rotation.
-
- #any GameObject.type
-
Type of the object (one of the tables from the package openmw.types#types).
Type Inventory
Inventory of a player/NPC or a content of a container.
Field(s)
- Inventory:countOf(recordId)
-
The number of items with given recordId.
Parameter
-
#string recordId
:
Return value
#number:
-
- Inventory:find(recordId)
-
Get first item with given recordId from the inventory.
Returns nil if not found.
Parameter
-
#string recordId
:
Return value
Usage:
inventory:find('gold_001')
-
- Inventory:findAll(recordId)
-
Get all items with given recordId from the inventory.
Parameter
-
#string recordId
:
Return value
Usage:
for _, item in ipairs(inventory:findAll('common_shirt_01')) do ... end
-
- Inventory:getAll(type)
-
Get all items of given type from the inventory.
Parameter
-
type
: (optional) items type (see openmw.types#types)
Return value
Usage:
local types = require('openmw.types') local self = require('openmw.self') local playerInventory = types.Actor.inventory(self.object) local all = playerInventory:getAll() local weapons = playerInventory:getAll(types.Weapon)
-
- Inventory:isResolved()
-
Checks if the inventory has a resolved item list.
Return value
#boolean:
Usage:
inventory:isResolved()
- Inventory:resolve()
-
Will resolve the inventory, filling it with levelled items if applicable, making its contents permanent.
Must be used in a global script.
Usage:
inventory:resolve()
Type Magic
Field(s)
- #MagicEffectId Magic.EFFECT_TYPE
-
Possible #MagicEffectId values
- #EnchantmentType Magic.ENCHANTMENT_TYPE
-
Possible #EnchantmentType values
- #SpellRange Magic.RANGE
-
Possible #SpellRange values
- #SpellType Magic.SPELL_TYPE
-
Possible #SpellType values
- #map<#number,#MagicEffect> Magic.effects
-
Map from #MagicEffectId to #MagicEffect
Usages:
-- Print all harmful effects for _, effect in pairs(core.magic.effects) do if effect.harmful then print(effect.name) end end
-- Look up the record of a specific effect and print its icon local mgef = core.magic.effects[core.magic.EFFECT_TYPE.Reflect] print('Reflect Icon: '..tostring(mgef.icon))
- #list<#Enchantment> Magic.enchantments
-
List of all #Enchantments.
Usages:
local enchantment = core.magic.enchantments['marara's boon'] -- get by id
local enchantment = core.magic.enchantments[1] -- get by index
-- Print all enchantments with constant effect for _, ench in pairs(core.magic.enchantments) do if ench.type == core.magic.ENCHANTMENT_TYPE.ConstantEffect then print(ench.id) end end
- #list<#Spell> Magic.spells
-
List of all #Spells.
Usages:
local spell = core.magic.spells['thunder fist'] -- get by id
local spell = core.magic.spells[1] -- get by index
-- Print all powers for _, spell in pairs(core.magic.spells) do if spell.types == core.magic.SPELL_TYPE.Power then print(spell.name) end end
Type MagicEffect
Field(s)
- #number MagicEffect.baseCost
- #boolean MagicEffect.harmful
- #string MagicEffect.icon
-
Effect Icon Path
- #string MagicEffect.id
-
Effect ID
- #string MagicEffect.name
-
Localized name of the effect
- #string MagicEffect.school
-
Skill ID that is this effect's school
Type MagicEffectId
core.magic.EFFECT_TYPE
Field(s)
- #number MagicEffectId.AbsorbAttribute
-
"absorbattribute"
- #number MagicEffectId.AbsorbFatigue
-
"absorbfatigue"
- #number MagicEffectId.AbsorbHealth
-
"absorbhealth"
- #number MagicEffectId.AbsorbMagicka
-
"absorbmagicka"
- #number MagicEffectId.AbsorbSkill
-
"absorbskill"
- #number MagicEffectId.AlmsiviIntervention
-
"almsiviintervention"
- #number MagicEffectId.Blind
-
"blind"
- #number MagicEffectId.BoundBattleAxe
-
"boundbattleaxe"
- #number MagicEffectId.BoundBoots
-
"boundboots"
- #number MagicEffectId.BoundCuirass
-
"boundcuirass"
- #number MagicEffectId.BoundDagger
-
"bounddagger"
- #number MagicEffectId.BoundGloves
-
"boundgloves"
- #number MagicEffectId.BoundHelm
-
"boundhelm"
- #number MagicEffectId.BoundLongbow
-
"boundlongbow"
- #number MagicEffectId.BoundLongsword
-
"boundlongsword"
- #number MagicEffectId.BoundMace
-
"boundmace"
- #number MagicEffectId.BoundShield
-
"boundshield"
- #number MagicEffectId.BoundSpear
-
"boundspear"
- #number MagicEffectId.Burden
-
"burden"
- #number MagicEffectId.CalmCreature
-
"calmcreature"
- #number MagicEffectId.CalmHumanoid
-
"calmhumanoid"
- #number MagicEffectId.Chameleon
-
"chameleon"
- #number MagicEffectId.Charm
-
"charm"
- #number MagicEffectId.CommandCreature
-
"commandcreature"
- #number MagicEffectId.CommandHumanoid
-
"commandhumanoid"
- #number MagicEffectId.Corprus
-
"corprus"
- #number MagicEffectId.CureBlightDisease
-
"cureblightdisease"
- #number MagicEffectId.CureCommonDisease
-
"curecommondisease"
- #number MagicEffectId.CureCorprusDisease
-
"curecorprusdisease"
- #number MagicEffectId.CureParalyzation
-
"cureparalyzation"
- #number MagicEffectId.CurePoison
-
"curepoison"
- #number MagicEffectId.DamageAttribute
-
"damageattribute"
- #number MagicEffectId.DamageFatigue
-
"damagefatigue"
- #number MagicEffectId.DamageHealth
-
"damagehealth"
- #number MagicEffectId.DamageMagicka
-
"damagemagicka"
- #number MagicEffectId.DamageSkill
-
"damageskill"
- #number MagicEffectId.DemoralizeCreature
-
"demoralizecreature"
- #number MagicEffectId.DemoralizeHumanoid
-
"demoralizehumanoid"
- #number MagicEffectId.DetectAnimal
-
"detectanimal"
- #number MagicEffectId.DetectEnchantment
-
"detectenchantment"
- #number MagicEffectId.DetectKey
-
"detectkey"
- #number MagicEffectId.DisintegrateArmor
-
"disintegratearmor"
- #number MagicEffectId.DisintegrateWeapon
-
"disintegrateweapon"
- #number MagicEffectId.Dispel
-
"dispel"
- #number MagicEffectId.DivineIntervention
-
"divineintervention"
- #number MagicEffectId.DrainAttribute
-
"drainattribute"
- #number MagicEffectId.DrainFatigue
-
"drainfatigue"
- #number MagicEffectId.DrainHealth
-
"drainhealth"
- #number MagicEffectId.DrainMagicka
-
"drainmagicka"
- #number MagicEffectId.DrainSkill
-
"drainskill"
- #number MagicEffectId.ExtraSpell
-
"extraspell"
- #number MagicEffectId.Feather
-
"feather"
- #number MagicEffectId.FireDamage
-
"firedamage"
- #number MagicEffectId.FireShield
-
"fireshield"
- #number MagicEffectId.FortifyAttack
-
"fortifyattack"
- #number MagicEffectId.FortifyAttribute
-
"fortifyattribute"
- #number MagicEffectId.FortifyFatigue
-
"fortifyfatigue"
- #number MagicEffectId.FortifyHealth
-
"fortifyhealth"
- #number MagicEffectId.FortifyMagicka
-
"fortifymagicka"
- #number MagicEffectId.FortifyMaximumMagicka
-
"fortifymaximummagicka"
- #number MagicEffectId.FortifySkill
-
"fortifyskill"
- #number MagicEffectId.FrenzyCreature
-
"frenzycreature"
- #number MagicEffectId.FrenzyHumanoid
-
"frenzyhumanoid"
- #number MagicEffectId.FrostDamage
-
"frostdamage"
- #number MagicEffectId.FrostShield
-
"frostshield"
- #number MagicEffectId.Invisibility
-
"invisibility"
- #number MagicEffectId.Jump
-
"jump"
- #number MagicEffectId.Levitate
-
"levitate"
- #number MagicEffectId.Light
-
"light"
- #number MagicEffectId.LightningShield
-
"lightningshield"
- #number MagicEffectId.Lock
-
"lock"
- #number MagicEffectId.Mark
-
"mark"
- #number MagicEffectId.NightEye
-
"nighteye"
- #number MagicEffectId.Open
-
"open"
- #number MagicEffectId.Paralyze
-
"paralyze"
- #number MagicEffectId.Poison
-
"poison"
- #number MagicEffectId.RallyCreature
-
"rallycreature"
- #number MagicEffectId.RallyHumanoid
-
"rallyhumanoid"
- #number MagicEffectId.Recall
-
"recall"
- #number MagicEffectId.Reflect
-
"reflect"
- #number MagicEffectId.RemoveCurse
-
"removecurse"
- #number MagicEffectId.ResistBlightDisease
-
"resistblightdisease"
- #number MagicEffectId.ResistCommonDisease
-
"resistcommondisease"
- #number MagicEffectId.ResistCorprusDisease
-
"resistcorprusdisease"
- #number MagicEffectId.ResistFire
-
"resistfire"
- #number MagicEffectId.ResistFrost
-
"resistfrost"
- #number MagicEffectId.ResistMagicka
-
"resistmagicka"
- #number MagicEffectId.ResistNormalWeapons
-
"resistnormalweapons"
- #number MagicEffectId.ResistParalysis
-
"resistparalysis"
- #number MagicEffectId.ResistPoison
-
"resistpoison"
- #number MagicEffectId.ResistShock
-
"resistshock"
- #number MagicEffectId.RestoreAttribute
-
"restoreattribute"
- #number MagicEffectId.RestoreFatigue
-
"restorefatigue"
- #number MagicEffectId.RestoreHealth
-
"restorehealth"
- #number MagicEffectId.RestoreMagicka
-
"restoremagicka"
- #number MagicEffectId.RestoreSkill
-
"restoreskill"
- #number MagicEffectId.Sanctuary
-
"sanctuary"
- #number MagicEffectId.Shield
-
"shield"
- #number MagicEffectId.ShockDamage
-
"shockdamage"
- #number MagicEffectId.Silence
-
"silence"
- #number MagicEffectId.SlowFall
-
"slowfall"
- #number MagicEffectId.Soultrap
-
"soultrap"
- #number MagicEffectId.Sound
-
"sound"
- #number MagicEffectId.SpellAbsorption
-
"spellabsorption"
- #number MagicEffectId.StuntedMagicka
-
"stuntedmagicka"
- #number MagicEffectId.SummonAncestralGhost
-
"summonancestralghost"
- #number MagicEffectId.SummonBear
-
"summonbear"
- #number MagicEffectId.SummonBonelord
-
"summonbonelord"
- #number MagicEffectId.SummonBonewalker
-
"summonbonewalker"
- #number MagicEffectId.SummonBonewolf
-
"summonbonewolf"
- #number MagicEffectId.SummonCenturionSphere
-
"summoncenturionsphere"
- #number MagicEffectId.SummonClannfear
-
"summonclannfear"
- #number MagicEffectId.SummonCreature04
-
"summoncreature04"
- #number MagicEffectId.SummonCreature05
-
"summoncreature05"
- #number MagicEffectId.SummonDaedroth
-
"summondaedroth"
- #number MagicEffectId.SummonDremora
-
"summondremora"
- #number MagicEffectId.SummonFabricant
-
"summonfabricant"
- #number MagicEffectId.SummonFlameAtronach
-
"summonflameatronach"
- #number MagicEffectId.SummonFrostAtronach
-
"summonfrostatronach"
- #number MagicEffectId.SummonGoldenSaint
-
"summongoldensaint"
- #number MagicEffectId.SummonGreaterBonewalker
-
"summongreaterbonewalker"
- #number MagicEffectId.SummonHunger
-
"summonhunger"
- #number MagicEffectId.SummonScamp
-
"summonscamp"
- #number MagicEffectId.SummonSkeletalMinion
-
"summonskeletalminion"
- #number MagicEffectId.SummonStormAtronach
-
"summonstormatronach"
- #number MagicEffectId.SummonWingedTwilight
-
"summonwingedtwilight"
- #number MagicEffectId.SummonWolf
-
"summonwolf"
- #number MagicEffectId.SunDamage
-
"sundamage"
- #number MagicEffectId.SwiftSwim
-
"swiftswim"
- #number MagicEffectId.Telekinesis
-
"telekinesis"
- #number MagicEffectId.TurnUndead
-
"turnundead"
- #number MagicEffectId.Vampirism
-
"vampirism"
- #number MagicEffectId.WaterBreathing
-
"waterbreathing"
- #number MagicEffectId.WaterWalking
-
"waterwalking"
- #number MagicEffectId.WeaknessToBlightDisease
-
"weaknesstoblightdisease"
- #number MagicEffectId.WeaknessToCommonDisease
-
"weaknesstocommondisease"
- #number MagicEffectId.WeaknessToCorprusDisease
-
"weaknesstocorprusdisease"
- #number MagicEffectId.WeaknessToFire
-
"weaknesstofire"
- #number MagicEffectId.WeaknessToFrost
-
"weaknesstofrost"
- #number MagicEffectId.WeaknessToMagicka
-
"weaknesstomagicka"
- #number MagicEffectId.WeaknessToNormalWeapons
-
"weaknesstonormalweapons"
- #number MagicEffectId.WeaknessToPoison
-
"weaknesstopoison"
- #number MagicEffectId.WeaknessToShock
-
"weaknesstoshock"
Type MagicEffectWithParams
Field(s)
- #string MagicEffectWithParams.affectedAttribute
-
Optional attribute ID
- #string MagicEffectWithParams.affectedSkill
-
Optional skill ID
- #number MagicEffectWithParams.area
- #number MagicEffectWithParams.duration
- #number MagicEffectWithParams.range
Type MagicSchoolData
Type ObjectList
List of GameObjects.
Implements iterables#List of #GameObject
ObjectList
is a list of #GameObject
.
Type Skill
core.stats.Skill
Field(s)
- Skill.record(recordId)
-
Returns a read-only #SkillRecord
Parameter
-
#string recordId
:
Return value
-
- #list<#SkillRecord> Skill.records
-
A read-only list of all #SkillRecords in the world database.
Type SkillRecord
Field(s)
- #string SkillRecord.attribute
-
The id of the skill's governing attribute
- #string SkillRecord.description
-
Human-readable description
- #string SkillRecord.icon
-
VFS path to the icon
- #string SkillRecord.id
-
Record id
- #string SkillRecord.name
-
Human-readable name
- #MagicSchoolData SkillRecord.school
-
Optional magic school
- #string SkillRecord.specialization
-
Skill specialization. Either combat, magic, or stealth.
Type Sound
Field(s)
- Sound.isEnabled()
-
Checks if sound system is enabled (any functions to play sounds are no-ops when it is disabled).
It can not be enabled or disabled during runtime.
Return value
#boolean:
Usage:
local enabled = core.sound.isEnabled();
- Sound.isSayActive(object)
-
Check if animated voiceover is playing
Parameter
-
#GameObject object
: Object on which we want to check an animated voiceover (optional)
Return value
#boolean:
Usages:
-- check voice for given object local isActive = isSayActive(object);
-- check global voice local isActive = isSayActive();
-
- Sound.isSoundFilePlaying(fileName, object)
-
Check if sound file is playing on given object
Parameters
-
#string fileName
: Path to sound file in VFS -
#GameObject object
: Object on which we want to check sound
Return value
#boolean:
Usage:
local isPlaying = core.sound.isSoundFilePlaying("Sound\\test.mp3", object);
-
- Sound.isSoundPlaying(soundId, object)
-
Check if sound is playing on given object
Parameters
-
#string soundId
: ID of Sound record to check -
#GameObject object
: Object on which we want to check sound
Return value
#boolean:
Usage:
local isPlaying = core.sound.isSoundPlaying("shock bolt", object);
-
- Sound.playSound3d(soundId, object, options)
-
Play a 3D sound, attached to object
Parameters
-
#string soundId
: ID of Sound record to play -
#GameObject object
: Object to which we attach the sound -
#table options
: An optional table with additional optional arguments. Can contain:timeOffset
- a floating point number >= 0, to some time (in second) from beginning of sound file (default: 0);volume
- a floating point number >= 0, to set a sound volume (default: 1);pitch
- a floating point number >= 0, to set a sound pitch (default: 1);loop
- a boolean, to set if sound should be repeated when it ends (default: false);
Usage:
local params = { timeOffset=0.1 volume=0.3, loop=false, pitch=1.0 }; core.sound.playSound3d("shock bolt", object, params)
-
- Sound.playSoundFile3d(fileName, object, options)
-
Play a 3D sound file, attached to object
Parameters
-
#string fileName
: Path to sound file in VFS -
#GameObject object
: Object to which we attach the sound -
#table options
: An optional table with additional optional arguments. Can contain:timeOffset
- a floating point number >= 0, to some time (in second) from beginning of sound file (default: 0);volume
- a floating point number >= 0, to set a sound volume (default: 1);pitch
- a floating point number >= 0, to set a sound pitch (default: 1);loop
- a boolean, to set if sound should be repeated when it ends (default: false);
Usage:
local params = { timeOffset=0.1 volume=0.3, loop=false, pitch=1.0 }; core.sound.playSoundFile3d("Sound\\test.mp3", object, params)
-
- Sound.say(fileName, object, text)
-
Play an animated voiceover.
Has two overloads:
- With an "object" argument: play sound for given object, with speaking animation if possible
- Without an "object" argument: play sound globally, without object
Parameters
-
#string fileName
: Path to sound file in VFS -
#GameObject object
: Object on which we want to play an animated voiceover (optional) -
#string text
: Subtitle text (optional)
Usages:
-- play voiceover for object and print messagebox core.sound.say("Sound\\Vo\\Misc\\voice.mp3", object, "Subtitle text")
-- play voiceover globally and print messagebox core.sound.say("Sound\\Vo\\Misc\\voice.mp3", "Subtitle text")
-- play voiceover for object without messagebox core.sound.say("Sound\\Vo\\Misc\\voice.mp3", object)
-- play voiceover globally without messagebox core.sound.say("Sound\\Vo\\Misc\\voice.mp3")
- #list<#SoundRecord> Sound.sounds
-
List of all #SoundRecords.
Usages:
local sound = core.sound.sounds['Ashstorm'] -- get by id
local sound = core.sound.sounds[1] -- get by index
-- Print all sound files paths for _, sound in pairs(core.sound.sounds) do print(sound.fileName) end
- Sound.stopSay(fileName, object)
-
Stop animated voiceover
Parameters
-
#string fileName
: Path to sound file in VFS -
#GameObject object
: Object on which we want to stop an animated voiceover (optional)
Usages:
-- stop voice for given object core.sound.stopSay(object);
-- stop global voice core.sound.stopSay();
-
- Sound.stopSound3d(soundId, object)
-
Stop a 3D sound, attached to object
Parameters
-
#string soundId
: ID of Sound record to stop -
#GameObject object
: Object on which we want to stop sound
Usage:
core.sound.stopSound("shock bolt", object);
-
- Sound.stopSoundFile3d(fileName, object)
-
Stop a 3D sound file, attached to object
Parameters
-
#string fileName
: Path to sound file in VFS -
#GameObject object
: Object on which we want to stop sound
Usage:
core.sound.stopSoundFile("Sound\\test.mp3", object);
-
Type SoundRecord
Field(s)
- #string SoundRecord.fileName
-
Normalized path to sound file in VFS
- #string SoundRecord.id
-
Sound id
- #number SoundRecord.maxRange
-
Raw maximal range value, from 0 to 255
- #number SoundRecord.minRange
-
Raw minimal range value, from 0 to 255
- #number SoundRecord.volume
-
Raw sound volume, from 0 to 255
Type Spell
Field(s)
- #number Spell.cost
- #list<#MagicEffectWithParams> Spell.effects
-
The effects (#MagicEffectWithParams) of the spell
- #string Spell.id
-
Spell id
- #string Spell.name
-
Spell name
- #number Spell.type
Type SpellRange
core.magic.RANGE
Field(s)
- #number SpellRange.Self
-
Applied on self
- #number SpellRange.Target
-
Ranged spell
- #number SpellRange.Touch
-
On touch
Type SpellType
core.magic.SPELL_TYPE
Field(s)
- #number SpellType.Ability
-
Innate ability, always in effect
- #number SpellType.Blight
-
Blight disease
- #number SpellType.Curse
-
Curse
- #number SpellType.Disease
-
Common disease
- #number SpellType.Power
-
Power, can be used once a day
- #number SpellType.Spell
-
Normal spell, must be cast and costs mana
Type Stats
Field(s)
- #Attribute Stats.Attribute
-
#Attribute functions
- #Skill Stats.Skill
-
#Skill functions
Type TeleportOptions
Either table with options or openmw.util#Vector3 rotation.
Field(s)
- #boolean TeleportOptions.onGround
-
If true, adjust destination position to the ground.
- openmw.util#Transform TeleportOptions.rotation
-
New rotation; if missing, then the current rotation is used.