Class Objects.Moveable

Represents a moveable object in the game world.

Examples include the player, traps, enemies, doors, and pickups. See also Objects.LaraObject for player-specific features.

Functions

Moveable(objectID, name, position, [rotation], [roomNumber], [animNumber], [frameNumber], [hp], [OCB], [AIBits]) Used to generate a new moveable dynamically at runtime.
Moveable:GetObjectID() Retrieve the object ID.
Moveable:SetObjectID(objectID) Change the object's ID.
Moveable:SetOnHit(function) Set the name of the function to be called when the moveable is shot by Lara.
Moveable:SetOnKilled(function) Set the name of the function to be called when the moveable is destroyed/killed.
Moveable:SetOnCollidedWithObject(function) Set the function to be called when this moveable collides with another moveable.
Moveable:SetOnCollidedWithRoom(function) Set the function called when this moveable collides with room geometry (e.g.
Moveable:GetName() Get the moveable's name (its unique string identifier).
Moveable:SetName(name) Set the moveable's name (its unique string identifier).
Moveable:GetPosition() Get the moveable's position.
Moveable:SetPosition(position, [updateRoom]) Set the moveable's position.
Moveable:GetJointPosition(jointIndex, [offset]) Get the moveable's joint position with an optional relative offset.
Moveable:GetJointRotation(index) Get the object's joint rotation.
Moveable:GetRotation() Get the moveable's rotation.
Moveable:GetScale() Get the moveable's visual scale.
Moveable:SetRotation(rotation) Set the moveable's rotation.
Moveable:SetScale(scale) Set the moveable's visual scale.
Moveable:GetHP() Get current HP (hit points / health points).
Moveable:SetHP(HP) Set current HP (hit points / health points).
Moveable:GetSlotHP() Get HP definded for that object type (hit points / health points).
Moveable:GetOCB() Get OCB (object code bit) of the moveable.
Moveable:SetOCB(OCB) Set OCB (object code bit) of the moveable.
Moveable:SetEffect(effect, [timeout]) Set the effect for this moveable.
Moveable:SetCustomEffect(color1, color2, [timeout]) Set custom colored burn effect to moveable.
Moveable:GetEffect() Get current moveable effect.
Moveable:GetItemFlags(index) Get the value stored in ItemFlags[index].
Moveable:SetItemFlags(value, index) Stores a value in ItemFlags[index].
Moveable:GetLocationAI() Get the location value stored in the Enemy AI.
Moveable:SetLocationAI(value) Updates the location in the enemy AI with the given value.
Moveable:GetColor() Get the moveable's color.
Moveable:SetColor(color) Set the moveable's color.
Moveable:GetAIBits() Get AIBits of object.
Moveable:SetAIBits(bits) Set AIBits of object.
Moveable:GetState() Retrieve the index of the current state.
Moveable:GetTargetState() Retrieve the index of the target state.
Moveable:SetState(index) Set the object's state to the one specified by the given index.
Moveable:GetAnimSlot() Retrieve the slot ID of the animation.
Moveable:GetAnim() Retrieve the index of the current animation.
Moveable:SetAnim(index, [slot]) Set the object's animation to the one specified by the given index.
Moveable:GetFrame() Retrieve frame number.
Moveable:GetVelocity() Get the object's velocity.
Moveable:SetVelocity(velocity) Set the object's velocity to specified value.
Moveable:SetFrame(frame) Set frame number.
Moveable:GetEndFrame() Get the end frame number of the moveable's active animation.
Moveable:GetActive() Determine whether the moveable is active or not.
Moveable:GetHitStatus() Get the hit status of the moveable.
Moveable:GetRoom() Get the current room of the moveable.
Moveable:GetRoomNumber() Get the current room number of the moveable.
Moveable:SetRoomNumber(roomID) Set the room ID of a moveable.
Moveable:GetStatus() Get the moveable's status.
Moveable:SetStatus(status) Set the moveable's status.
Moveable:GetMeshCount() Get number of meshes for a particular object.
Moveable:GetMeshVisible(index) Get state of specified mesh visibility of object.
Moveable:SetMeshVisible(index, isVisible) Makes specified mesh visible or invisible.
Moveable:ShatterMesh(index) Shatters specified mesh and makes it invisible.
Moveable:GetMeshSwapped(index) Get state of specified mesh swap of object.
Moveable:SwapMesh(index, slotIndex, [swapIndex]) Set state of specified mesh swap of object.
Moveable:UnswapMesh(index) Set state of specified mesh swap of object.
Moveable:Enable([timeout]) Enable the item, as if a trigger for it had been stepped on.
Moveable:Disable() Disable the item, as if an antitrigger for it had been stepped on.
Moveable:Explode() Explode this moveable.
Moveable:Shatter() Shatter this moveable.
Moveable:GetCollidable() Get the item's collision state.
Moveable:SetCollidable(collidable) Set the item's collision.
Moveable:SetVisible(visible) Set the item's visibility.
Moveable:GetValid() Test if the object is in a valid state.
Moveable:Destroy() Destroy the moveable.
Moveable:AttachObjCamera(mesh, target, mesh) Attach camera to an object.
Moveable:AnimFromObject(objectID, animNumber, stateID) Borrow animation from an object.


Functions

Moveable(objectID, name, position, [rotation], [roomNumber], [animNumber], [frameNumber], [hp], [OCB], [AIBits])
Used to generate a new moveable dynamically at runtime. For more information on each parameter, see the associated getters and setters. If you do not know what to set for these, most can just be ignored (see usage).

Parameters:

  • objectID ObjID Object ID.
  • name string Lua name.
  • position Vec3 Position in level.
  • rotation Rotation Rotation about x, y, and z axes. Optional.
  • roomNumber int The room number the moveable is in. Needed if you are dealing with overlapping rooms and need to force certain room number. Optional.
  • animNumber int Animation number. Optional.
  • frameNumber int Frame number. Optional.
  • hp int Hit points. Optional.
  • OCB int Object code bits. Optional.
  • AIBits table Table with six AI bits. Optional.

Returns:

    Moveable A new Moveable object.

Usage:

    local item = Moveable(
    	TEN.Objects.ObjID.PISTOLS_ITEM, -- object id
    	"test", -- name
    	Vec3(18907, 0, 21201)) -- position
Moveable:GetObjectID()
Retrieve the object ID.

Returns:

    ObjID A number representing the ID of the object.
Moveable:SetObjectID(objectID)
Change the object's ID. This will literally change the object.

Parameters:

  • objectID ObjID The new ID.

Usage:

    shiva = TEN.Objects.GetMoveableByName("shiva_60")
    shiva:SetObjectID(TEN.Objects.ObjID.BIGMEDI_ITEM)
Moveable:SetOnHit(function)
Set the name of the function to be called when the moveable is shot by Lara. Note that this will be triggered twice when shot with both pistols at once.

Parameters:

  • function function Callback function in LevelFuncs hierarchy to call when moveable is shot.
Moveable:SetOnKilled(function)
Set the name of the function to be called when the moveable is destroyed/killed. Note that enemy death often occurs at the end of an animation, and not at the exact moment the enemy's HP becomes zero.

Parameters:

  • function function Callback function in LevelFuncs hierarchy to call when moveable is killed.

Usage:

    LevelFuncs.baddyKilled = function(theBaddy) print("You killed a baddy!") end
    baddy:SetOnKilled(LevelFuncs.baddyKilled)
Moveable:SetOnCollidedWithObject(function)
Set the function to be called when this moveable collides with another moveable.

Parameters:

  • function function Callback function to be called (must be in LevelFuncs hierarchy). This function can take two arguments; these will store the two Moveables taking part in the collision.

Usage:

    -- obj1 is the collision moveable
    -- obj2 is the collider moveable
    
    LevelFuncs.objCollided = function(obj1, obj2)
        print(obj1:GetName() .. " collided with " .. obj2:GetName())
    end
    baddy:SetOnCollidedWithObject(LevelFuncs.objCollided)
Moveable:SetOnCollidedWithRoom(function)
Set the function called when this moveable collides with room geometry (e.g. a wall or floor). This function can take an argument that holds the Moveable that collided with geometry.

Parameters:

  • function function Callback function to be called (must be in LevelFuncs hierarchy).

Usage:

    LevelFuncs.roomCollided = function(obj)
        print(obj:GetName() .. " collided with room geometry")
    end
    baddy:SetOnCollidedWithRoom(LevelFuncs.roomCollided)
Moveable:GetName()
Get the moveable's name (its unique string identifier). This corresponds with the "Lua Name" field in an object's properties in Tomb Editor.

Returns:

    string The moveable's name.
Moveable:SetName(name)
Set the moveable's name (its unique string identifier). It cannot be blank and cannot share a name with any existing object.

Parameters:

  • name string The new moveable's name.

Returns:

    bool true if name was successfully set, false otherwise (e.g. if another moveable has the name already).
Moveable:GetPosition()
Get the moveable's position.

Returns:

    Vec3 Moveable's position.
Moveable:SetPosition(position, [updateRoom])
Set the moveable's position.

Parameters:

  • position Vec3 The new position of the moveable.
  • updateRoom bool Will room changes be automatically detected? Set to false if you are using overlapping rooms. Default: true.
Moveable:GetJointPosition(jointIndex, [offset])
Get the moveable's joint position with an optional relative offset.

Parameters:

  • jointIndex int Index of a joint to get position.
  • offset Vec3 Offset relative to the joint. Optional.

Returns:

    Vec3 World position.
Moveable:GetJointRotation(index)
Get the object's joint rotation.

Parameters:

  • index int Index of a joint to get rotation.

Returns:

    Rotation Moveable's joint rotation.
Moveable:GetRotation()
Get the moveable's rotation.

Returns:

    Rotation Moveable's rotation.
Moveable:GetScale()
Get the moveable's visual scale.

Returns:

    Vec3 Moveable's visual scale.
Moveable:SetRotation(rotation)
Set the moveable's rotation.

Parameters:

  • rotation Rotation The moveable's new rotation.
Moveable:SetScale(scale)
Set the moveable's visual scale. Does not affect collision.

Parameters:

  • scale Vec3 New visual scale.
Moveable:GetHP()
Get current HP (hit points / health points).

Returns:

    int The amount of HP the moveable currently has.
Moveable:SetHP(HP)
Set current HP (hit points / health points). Clamped to [0, 32767] for "intelligent" entities (i.e. anything with AI); clamped to [-32767, 32767] otherwise.

Parameters:

  • HP int The amount of HP to give the moveable.
Moveable:GetSlotHP()
Get HP definded for that object type (hit points / health points).

Returns:

    int The moveable's slot default hit points.
Moveable:GetOCB()
Get OCB (object code bit) of the moveable.

Returns:

    int The moveable's current OCB value.
Moveable:SetOCB(OCB)
Set OCB (object code bit) of the moveable.

Parameters:

  • OCB int The new value for the moveable's OCB.
Moveable:SetEffect(effect, [timeout])
Set the effect for this moveable.

Parameters:

  • effect EffectID Type of effect to assign.
  • timeout float Time (in seconds) after which effect turns off. Optional.
Moveable:SetCustomEffect(color1, color2, [timeout])
Set custom colored burn effect to moveable.

Parameters:

  • color1 Color The primary color of the effect (also used for lighting).
  • color2 Color The secondary color of the effect.
  • timeout float Time (in seconds) after which effect turns off. Optional.
Moveable:GetEffect()
Get current moveable effect.

Returns:

    EffectID Effect type currently assigned.
Moveable:GetItemFlags(index)
Get the value stored in ItemFlags[index].

Parameters:

  • index int Index of the ItemFlag, can be between 0 and 7.

Returns:

    int The value contained in the ItemFlags[index].
Moveable:SetItemFlags(value, index)
Stores a value in ItemFlags[index].

Parameters:

  • value short Value to store in the moveable's ItemFlags[index].
  • index int Index of the ItemFlag where to store the value.
Moveable:GetLocationAI()
Get the location value stored in the Enemy AI.

Returns:

    short The value contained in the LocationAI of the creature.
Moveable:SetLocationAI(value)
Updates the location in the enemy AI with the given value.

Parameters:

  • value short Value to store.
Moveable:GetColor()
Get the moveable's color.

Returns:

    Color Moveable's color.
Moveable:SetColor(color)
Set the moveable's color.

Parameters:

  • color Color The new color of the moveable.
Moveable:GetAIBits()

Get AIBits of object. This will return a table with six values, each corresponding to an active behaviour. If the object is in a certain AI mode, the table will have a 1 in the corresponding cell. Otherwise, the cell will hold a 0.

1 - Guard
2 - Ambush
3 - Patrol 1
4 - Modify
5 - Follow
6 - Patrol 2

Returns:

    table A table of AI bits.
Moveable:SetAIBits(bits)
Set AIBits of object. Use this to force a moveable into a certain AI mode or modes, as if a certain nullmesh (or more than one) had suddenly spawned beneath their feet.

Parameters:

  • bits table A table of AI bits.

Usage:

    local sas = TEN.Objects.GetMoveableByName("sas_enemy")
    sas:SetAIBits({1, 0, 0, 0, 0, 0})
Moveable:GetState()
Retrieve the index of the current state. This corresponds to the number shown in the item's state ID field in WadTool.

Returns:

    int The index of the active state.
Moveable:GetTargetState()
Retrieve the index of the target state. This corresponds to the state the object is trying to get into, which is sometimes different from the active state.

Returns:

    int The index of the target state.
Moveable:SetState(index)
Set the object's state to the one specified by the given index. Performs no bounds checking. Ensure the number given is correct, else object may end up in corrupted animation state.

Parameters:

  • index int The index of the desired state.
Moveable:GetAnimSlot()
Retrieve the slot ID of the animation. In certain cases, moveable may play animations from another object slot. Use this function when you need to identify such cases.

Returns:

    int Animation slot ID.
Moveable:GetAnim()
Retrieve the index of the current animation. This corresponds to the number shown in the item's animation list in WadTool.

Returns:

    int The index of the active animation.
Moveable:SetAnim(index, [slot])
Set the object's animation to the one specified by the given index. Performs no bounds checking. Ensure the number given is correct, else object may end up in corrupted animation state.

Parameters:

  • index int The index of the desired animation.
  • slot int Slot ID of the desired anim (if omitted, moveable's own slot ID is used). Optional.
Moveable:GetFrame()
Retrieve frame number. This is the current frame of the object's active animation.

Returns:

    int The current frame of the active animation.
Moveable:GetVelocity()
Get the object's velocity. In most cases, only Z and Y components are used as forward and vertical velocity. In some cases, primarily NPCs, X component is used as side velocity.

Returns:

    Vec3 Current object velocity.
Moveable:SetVelocity(velocity)
Set the object's velocity to specified value. In most cases, only Z and Y components are used as forward and vertical velocity. In some cases, primarily NPCs, X component is used as side velocity.

Parameters:

  • velocity Vec3 Velocity represented as vector.
Moveable:SetFrame(frame)
Set frame number. This will move the animation to the given frame. The number of frames in an animation can be seen under the heading "End frame" in the WadTool animation editor. If the animation has no frames, the only valid argument is -1.

Parameters:

  • frame int The new frame number.
Moveable:GetEndFrame()
Get the end frame number of the moveable's active animation. This is the "End Frame" set in WADTool for the animation.()

Returns:

    int End frame number of the active animation.
Moveable:GetActive()
Determine whether the moveable is active or not.

Returns:

    bool True if the moveable is active.
Moveable:GetHitStatus()
Get the hit status of the moveable.

Returns:

    bool true if the moveable was hit by something in the last gameplay frame, false otherwise.
Moveable:GetRoom()
Get the current room of the moveable.

Returns:

    Room Current room of the moveable.
Moveable:GetRoomNumber()
Get the current room number of the moveable.

Returns:

    int Number representing the current room of the moveable.
Moveable:SetRoomNumber(roomID)
Set the room ID of a moveable. Use this if not using SetPosition's automatic room update - for example, when dealing with overlapping rooms.

Parameters:

  • roomID int New room's ID.

Usage:

    local sas = TEN.Objects.GetMoveableByName("sas_enemy")
    sas:SetRoomNumber(newRoomID)
    sas:SetPosition(newPos, false)
Moveable:GetStatus()
Get the moveable's status.

Returns:

    MoveableStatus Status.
Moveable:SetStatus(status)
Set the moveable's status.

Parameters:

Moveable:GetMeshCount()
Get number of meshes for a particular object. Returns number of meshes in an object

Returns:

    int Number of meshes.
Moveable:GetMeshVisible(index)
Get state of specified mesh visibility of object. Returns true if specified mesh is visible on an object, and false if it is not visible.

Parameters:

  • index int Index of a mesh.

Returns:

    bool Visibility status.
Moveable:SetMeshVisible(index, isVisible)
Makes specified mesh visible or invisible. Use this to show or hide a specified mesh of an object.

Parameters:

  • index int Index of a mesh.
  • isVisible bool true if you want the mesh to be visible, false otherwise.
Moveable:ShatterMesh(index)
Shatters specified mesh and makes it invisible. Note that you can re-enable mesh later by using SetMeshVisible().

Parameters:

  • index int Index of a mesh to shatter.
Moveable:GetMeshSwapped(index)
Get state of specified mesh swap of object. Returns true if specified mesh is swapped on an object, and false if it is not swapped.

Parameters:

  • index int Index of a mesh.

Returns:

    bool Mesh swap status.
Moveable:SwapMesh(index, slotIndex, [swapIndex])
Set state of specified mesh swap of object. Use this to swap specified mesh of an object.

Parameters:

  • index int Index of a mesh.
  • slotIndex int Index of a slot to get meshswap from.
  • swapIndex int Index of a mesh from meshswap slot to use. Optional.
Moveable:UnswapMesh(index)
Set state of specified mesh swap of object. Use this to bring back original unswapped mesh

Parameters:

  • index int Index of a mesh to unswap.
Moveable:Enable([timeout])
Enable the item, as if a trigger for it had been stepped on.

Parameters:

  • timeout float Time (in seconds) after which moveable automatically disables. Optional.
Moveable:Disable()
Disable the item, as if an antitrigger for it had been stepped on. For example, it will close an open door or extinguish a flame emitter. Note that this will not trigger an OnKilled callback.
Moveable:Explode()
Explode this moveable. Also kills and disables it.
Moveable:Shatter()
Shatter this moveable. Also kills and disables it.
Moveable:GetCollidable()
Get the item's collision state.

Returns:

    bool Item's collision state.
Moveable:SetCollidable(collidable)
Set the item's collision.

Parameters:

  • collidable bool true if the caller should be collidable, false if no collision should occur.
Moveable:SetVisible(visible)
Set the item's visibility. An invisible item will have collision turned off, as if it no longer exists in the game world.

Parameters:

  • visible bool true if the caller should become visible, false if it should become invisible.
Moveable:GetValid()
Test if the object is in a valid state. Indicates that it has not been destroyed through Lua or killed by Lara.

Returns:

    bool true if the object is still not destroyed.
Moveable:Destroy()
Destroy the moveable. This will mean it can no longer be used, except to re-initialize it with another object.
Moveable:AttachObjCamera(mesh, target, mesh)
Attach camera to an object.

Parameters:

  • mesh int Mesh of a target moveable to use as a camera target.
  • target Moveable Target moveable to attach camera to.
  • mesh int Mesh of a target moveable to use as a camera target.
Moveable:AnimFromObject(objectID, animNumber, stateID)
Borrow animation from an object.

Parameters:

  • objectID ObjID Object ID to take animation and state ID from.
  • animNumber int Animation from object.
  • stateID int State from object.
generated by TEN-LDoc (a fork of LDoc 1.4.6)