Skip to content

mwscript⚓︎

Warning

This API is deprecated. See below for more information about what to use instead.

The mwscript library allows vanilla mwscript functions to be called. This is not always ideal, and this library is deprecated. Avoid using it if at all possible.

Functions⚓︎

mwscript.activate⚓︎

Use tes3reference:activate() or tes3.setAIActivate() instead. Wrapper for the Activate mwscript function.

mwscript.activate({ reference = ... })

Parameters:

  • params (table): Optional.
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.

mwscript.addItem⚓︎

Use tes3.addItem(), tes3inventory:addItem(), or depending on your needs tes3mobileActor:equip() instead. Wrapper for the AddItem mwscript function.

local executed = mwscript.addItem({ reference = ..., item = ..., count = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • item (tes3item, string): The item to be added.
    • count (number): Default: 1. The number of items to be added.

Returns:

  • executed (boolean)

mwscript.addSoulGem⚓︎

use tes3.addItem() with the soul parameter instead. Wrapper for the AddSoulGem mwscript function.

local executed = mwscript.addSoulGem({ reference = ..., creature = ..., soulgem = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • creature (tes3creature, string): The creature to be stored in the soul gem.
    • soulgem (tes3misc, string): The soul gem to store the soul in.

Returns:

  • executed (boolean)

mwscript.addSpell⚓︎

Use tes3.addSpell() or tes3spellList:add() instead. Wrapper for the AddSpell mwscript function.

local executed = mwscript.addSpell({ reference = ..., spell = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • spell (tes3spell, string)

Returns:

  • executed (boolean)

mwscript.addToLevCreature⚓︎

Use tes3leveledCreature:insert() instead. Wrapper for the AddToLevCreature mwscript function.

local executed = mwscript.addToLevCreature({ list = ..., creature = ..., level = ... })

Parameters:

  • params (table)
    • list (tes3leveledCreature, string): Leveled creature list to add a creature to.
    • creature (tes3actor, string): Creature to add to the list.
    • level (number): Default: 0. Minimum level for the creature to spawn.

Returns:

  • executed (boolean)

mwscript.addToLevItem⚓︎

Use tes3leveledItem:insert() instead. Wrapper for the AddToLevItem mwscript function.

local executed = mwscript.addToLevItem({ list = ..., item = ..., level = ... })

Parameters:

  • params (table)
    • list (tes3leveledItem, string): Leveled item list to add an item to.
    • item (tes3item, string): Item to add to the list.
    • level (number): Default: 0. Minimum level for the item to spawn.

Returns:

  • executed (boolean)

mwscript.addTopic⚓︎

Use tes3.addTopic() instead. Wrapper for the AddTopic mwscript function.

local executed = mwscript.addTopic({ topic = ... })

Parameters:

Returns:

  • executed (boolean)

mwscript.aiTravel⚓︎

Use tes3.setAITravel() instead. Wrapper for the AITravel mwscript function.

local executed = mwscript.aiTravel({ reference = ..., x = ..., y = ..., z = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • x (number)
    • y (number)
    • z (number)

Returns:

  • executed (boolean)

mwscript.disable⚓︎

Use tes3reference:disable() or tes3.setEnabled() instead. Wrapper for the Disable mwscript function.

local executed = mwscript.disable({ reference = ..., modify = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • modify (boolean): Default: true. Set the object as modified.

Returns:

  • executed (boolean)

mwscript.drop⚓︎

Use tes3.dropItem() or tes3inventory:dropItem() instead. Wrapper for the Drop mwscript function.

local executed = mwscript.drop({ reference = ..., item = ..., count = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • item (tes3item, string): The item to be dropped.
    • count (number): Default: 1. The number of items to drop.

Returns:

  • executed (boolean)

mwscript.enable⚓︎

Use tes3.setEnabled() or tes3reference:enable() instead. Wrapper for the Enable mwscript function.

local executed = mwscript.enable({ reference = ..., modify = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • modify (boolean): Default: true. Set the object as modified.

Returns:

  • executed (boolean)

mwscript.equip⚓︎

Use tes3mobileActor:equip() or tes3mobileActor.combatSession:changeEquipment() instead. Wrapper for the Equip mwscript function.

local executed = mwscript.equip({ reference = ..., item = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • item (tes3item, string): The item to be equipped.

Returns:

  • executed (boolean)

mwscript.explodeSpell⚓︎

Use tes3.cast() instead. Wrapper for the ExplodeSpell mwscript function.

local executed = mwscript.explodeSpell({ reference = ..., spell = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • spell (tes3spell, string)

Returns:

  • executed (boolean)

mwscript.getButtonPressed⚓︎

Use tes3.messageBox() instead. Wrapper for the GetButtonPressed mwscript function.

local buttonIndex = mwscript.getButtonPressed()

Returns:

  • buttonIndex (number)

mwscript.getDetected⚓︎

Use tes3mobileActor.isPlayerDetected or depending on what you are doing, detectSneak event may be desirable. Wrapper for the GetDetected mwscript function.

local result = mwscript.getDetected({ reference = ..., target = ... })

Parameters:

Returns:

  • result (boolean)

mwscript.getDisabled⚓︎

Use object.disabled on any object inheriting from tes3baseObject. Wrapper for the GetDisabled mwscript function.

local result = mwscript.getDisabled({ reference = ... })

Parameters:

  • params (table): Optional.
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.

Returns:

  • result (boolean)

mwscript.getDistance⚓︎

Use tes3reference.position or tes3mobileActor.position to compute the distance or depending on the desired effect, tes3mobileActor.playerDistance. Wrapper for the GetDistance mwscript function.

local result = mwscript.getDistance({ reference = ..., target = ... })

Parameters:

Returns:

  • result (boolean)

mwscript.getItemCount⚓︎

Use tes3.getItemCount() instead. Wrapper for the GetItemCount mwscript function.

local result = mwscript.getItemCount({ reference = ..., item = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • item (tes3item, string)

Returns:

  • result (number)

mwscript.getPCJumping⚓︎

Use tes3.mobilePlayer.isJumping instead. Wrapper for the GetPCJumping mwscript function.

local result = mwscript.getPCJumping()

Returns:

  • result (boolean)

mwscript.getPCRunning⚓︎

Use tes3.mobilePlayer.isRunning instead. Wrapper for the GetPCRunning mwscript function.

local result = mwscript.getPCRunning()

Returns:

  • result (boolean)

mwscript.getPCSneaking⚓︎

Use tes3.mobilePlayer.isSneaking instead. Wrapper for the GetPCSneaking mwscript function.

local result = mwscript.getPCSneaking()

Returns:

  • result (boolean)

mwscript.getReference⚓︎

Use tes3globalScript.reference instead. Returns the script target for the currently running Morrowind script, if any.

local result = mwscript.getReference()

Returns:


mwscript.getScript⚓︎

Returns the currently running Morrowind script, if any.

local result = mwscript.getScript()

Returns:


mwscript.getSpellEffects⚓︎

Use tes3.isAffectedBy() or tes3mobileActor:isAffectedByObject() instead. Wrapper for the GetSpellEffects mwscript function.

local result = mwscript.getSpellEffects({ reference = ..., spell = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • spell (tes3spell, string)

Returns:

  • result (boolean)

mwscript.hasItemEquipped⚓︎

Use tes3actor:hasItemEquipped() or tes3.getEquippedItem() instead. Wrapper for the HasItemEquipped mwscript function.

local result = mwscript.hasItemEquipped({ reference = ..., item = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • item (tes3item, string): The item to check for.

Returns:

  • result (boolean)

mwscript.placeAtPC⚓︎

Use tes3.createReference() instead. Wrapper for the PlaceAtPC mwscript function.

local lastPlacedReference = mwscript.placeAtPC({ reference = ..., object = ..., count = ..., distance = ..., direction = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • object (tes3object, string): The object to place.
    • count (number): Default: 1.
    • distance (number): Default: 256.
    • direction (number): Default: 1.

Returns:


mwscript.playSound⚓︎

Use tes3.playSound(), tes3sound:play() method, or tes3.playItemPickupSound() instead. Wrapper for the PlaySound mwscript function.

local result = mwscript.playSound({ reference = ..., sound = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • sound (tes3sound, string)

Returns:

  • result (boolean)

mwscript.position⚓︎

Set tes3reference.position or tes3mobileActor.position to desired new position instead, or use tes3.positionCell(). Wrapper for the Position mwscript function.

local executed = mwscript.position({ reference = ..., cell = ..., x = ..., y = ..., z = ..., rotation = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • cell (string)
    • x (number): Default: 0.
    • y (number): Default: 0.
    • z (number): Default: 0.
    • rotation (number): Default: 0.

Returns:

  • executed (boolean)

mwscript.positionCell⚓︎

Use tes3.positionCell() instead. Wrapper for the PositionCell mwscript function.

local executed = mwscript.positionCell({ reference = ..., cell = ..., x = ..., y = ..., z = ..., rotation = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • cell (string)
    • x (number): Default: 0.
    • y (number): Default: 0.
    • z (number): Default: 0.
    • rotation (number): Default: 0.

Returns:

  • executed (boolean)

mwscript.removeItem⚓︎

Use tes3.removeItem(), tes3.removeItemData() or tes3inventory:removeItem() instead. Wrapper for the RemoveItem mwscript function.

local executed = mwscript.removeItem({ reference = ..., item = ..., count = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • item (tes3item, string): The item to be removed.
    • count (number): Default: 1. The number of items to be removed.

Returns:

  • executed (boolean)

mwscript.removeSpell⚓︎

Use tes3.removeSpell() or tes3spellList:remove() instead. Wrapper for the RemoveSpell mwscript function.

local executed = mwscript.removeSpell({ reference = ..., spell = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • spell (tes3spell, string)

Returns:

  • executed (boolean)

mwscript.scriptRunning⚓︎

Wrapper for the ScriptRunning mwscript function. Only checks global scripts.

local result = mwscript.scriptRunning({ script = ... })

Parameters:

Returns:

  • result (boolean)

mwscript.setDelete⚓︎

Use tes3reference:delete() instead. Marks the reference as deleted, and modified. Deleted reference isn't rendered nor is its local mwscript run.

local executed = mwscript.setDelete({ reference = ..., delete = ... })

Parameters:

  • params (table): Optional.
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • delete (boolean): Default: true. Setting this to true deletes the reference and triggers referenceDeactivated event. Setting this to false effectively undeletes/activates the reference and triggers referenceActivated event.

Returns:

  • executed (boolean)

mwscript.setLevel⚓︎

Wrapper for the SetLevel mwscript function.

local executed = mwscript.setLevel({ reference = ..., level = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • level (number)

Returns:

  • executed (boolean)

mwscript.startCombat⚓︎

Use tes3mobileActor:startCombat() instead. Wrapper for the StartCombat mwscript function.

local executed = mwscript.startCombat({ reference = ..., target = ... })

Parameters:

Returns:

  • executed (boolean)

mwscript.startScript⚓︎

Use tes3.runLegacyScript() instead. Wrapper for the StartCombat mwscript function. Starts the script as a global script.

local executed = mwscript.startScript({ reference = ..., script = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • script (tes3script, string)

Returns:

  • executed (boolean)

mwscript.stopCombat⚓︎

Use tes3mobileActor:stopCombat() instead. Wrapper for the StopCombat mwscript function.

local executed = mwscript.stopCombat({ reference = ..., target = ... })

Parameters:

Returns:

  • executed (boolean)

mwscript.stopScript⚓︎

Wrapper for the StopScript mwscript function. It can only stop global scripts.

local executed = mwscript.stopScript({ reference = ..., script = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • script (tes3script, string)

Returns:

  • executed (boolean)

mwscript.stopSound⚓︎

Use tes3.removeSound() or tes3sound:stop() instead. Wrapper for the StopSound mwscript function.

local result = mwscript.stopSound({ reference = ..., sound = ... })

Parameters:

  • params (table)
    • reference (tes3reference, tes3mobileActor, string): Optional. The target reference for this command to be executed on. Defaults to the normal script execution reference.
    • sound (tes3sound, string)

Returns:

  • result (boolean)

mwscript.wakeUpPC⚓︎

Use tes3.wakeUp() instead. Wrapper for the WakeUpPC mwscript function.

mwscript.wakeUpPC()