Class Objects.Moveable
Represents any object inside the game world.
Examples include traps, enemies, doors, pickups, and Lara herself.
Functions
Moveable(object, name, position, rotation, room, animNumber, frameNumber, hp, OCB, AIBits) | For more information on each parameter, see the associated getters and setters. |
Moveable:Enable() | Enable the item, as if a trigger for it had been stepped on. |
Moveable:Disable() | Disable the item |
Moveable:MakeInvisible() | Make the item invisible. |
Moveable:Explode() | Explode item. |
Moveable:Shatter() | Shatter item. |
Moveable:GetStatus() | Get the status of object. |
Moveable:SetOnHit(name) | 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. |
Moveable:GetOnHit() | Get the name of the function called when this moveable is shot |
Moveable:SetOnCollidedWithObject(name) | Set the name of the function called when this moveable collides with another moveable |
Moveable:GetOnCollidedWithObject() | Get the name of the function called when this moveable collides with another moveable |
Moveable:SetOnCollidedWithRoom(name) | Set the name of the function called when this moveable collides with room geometry (e.g. |
Moveable:GetOnCollidedWithRoom() | Get the name of the function called when this moveable collides with room geometry (e.g. |
Moveable:SetOnKilled(callback) | Set the name of the function to be called when the moveable is destroyed/killed |
Moveable:GetOnKilled() | Get the name of the function called when this moveable is killed |
Moveable:GetObjectID() | Retrieve the object ID |
Moveable:SetObjectID(ID) | Change the object's ID. |
Moveable:GetState() | Retrieve the index of the current state. |
Moveable:SetState(index) | Set the object's state to the one specified by the given index. |
Moveable:GetAnim() | Retrieve the index of the current animation. |
Moveable:SetAnim(index) | Set the object's animation to the one specified by the given index. |
Moveable:GetFrame() | Retrieve frame number. |
Moveable:SetFrame(frame) | Set frame number. |
Moveable:GetHP() | Get current HP (hit points/health points) |
Moveable:SetHP(HP) | Set current HP (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:GetColor() | Get the moveable's color |
Moveable:SetColor(color) | Set the moveable's color |
Moveable:GetAIBits() | Get AIBits of object This will return a table with six values, each corresponding to an active behaviour. |
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. |
Moveable:MeshIsVisible(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. |
Moveable:ShowMesh(index) | Makes specified mesh visible Use this to show specified mesh of an object. |
Moveable:HideMesh(index) | Makes specified mesh invisible Use this to hide specified mesh of an object. |
Moveable:ShatterMesh(index) | Shatters specified mesh and makes it invisible Note that you can re-enable mesh later by using ShowMesh(). |
Moveable:MeshIsSwapped(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. |
Moveable:SwapMesh(index, index, optional) | Set state of specified mesh swap of object Use this to swap specified mesh of an object. |
Moveable:UnswapMesh(index) | Set state of specified mesh swap of object Use this to bring back original unswapped mesh |
Moveable:GetHitStatus() | Get the hit status of the object |
Moveable:GetActive() | Determine whether the moveable is active or not |
Moveable:GetRoom() | Get the current room of the object |
Moveable:SetRoom(ID) | Set room of object This is used in conjunction with SetPosition to teleport an item to a new room. |
Moveable:GetPosition() | Get the object's position |
Moveable:GetJointPosition() | Get the object's joint position |
Moveable:SetPosition(position) | Set the moveable's position If you are moving a moveable whose behaviour involves knowledge of room geometry, (e.g. |
Moveable:GetRotation() | Get the moveable's rotation |
Moveable:SetRotation(rotation) | Set the moveable's rotation |
Moveable:GetName() | Get the moveable's name (its unique string identifier) e.g. |
Moveable:SetName(string) | Set the moveable's name (its unique string identifier) e.g. |
Moveable:GetValid() | Test if the object is in a valid state (i.e. |
Moveable:Destroy() | Destroy the moveable. |
Functions
- Moveable(object, name, position, rotation, room, animNumber, frameNumber, hp, OCB, AIBits)
-
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:
- object ObjID ID
- name string Lua name of the item
- position Vec3 position in level
- rotation Rotation rotation about x, y, and z axes (default Rotation(0, 0, 0))
- room int room ID item is in
- animNumber int anim number (default 0)
- frameNumber int frame number (default 0)
- hp int HP of item (default 10)
- OCB int ocb of item (default 0)
- AIBits table table with AI bits (default {0,0,0,0,0,0})
Returns:
-
reference to new Moveable object
Usage:
local item = Moveable( TEN.ObjID.PISTOLS_ITEM, -- object id "test", -- name Vec3(18907, 0, 21201), Rotation(0,0,0), 0, -- room )
- Moveable:Enable()
- Enable the item, as if a trigger for it had been stepped on.
- Moveable:Disable()
- Disable the item
- Moveable:MakeInvisible()
- Make the item invisible. Use EnableItem to make it visible again.
- Moveable:Explode()
- Explode item. This also kills and disables item.
- Moveable:Shatter()
- Shatter item. This also kills and disables item.
- Moveable:GetStatus()
-
Get the status of object.
possible values:
0 - not active
1 - active
2 - deactivated
3 - invisibleReturns:
-
int
a number representing the status of the object
- Moveable:SetOnHit(name)
-
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:
- name string of callback function to be called
- Moveable:GetOnHit()
-
Get the name of the function called when this moveable is shot
Returns:
-
string
name of the function
- Moveable:SetOnCollidedWithObject(name)
-
Set the name of the function called when this moveable collides with another moveable
Parameters:
- name string of callback function to be called
- Moveable:GetOnCollidedWithObject()
-
Get the name of the function called when this moveable collides with another moveable
Returns:
-
string
name of the function
- Moveable:SetOnCollidedWithRoom(name)
-
Set the name of the function called when this moveable collides with room geometry (e.g. a wall or floor)
Parameters:
- name string of callback function to be called
- Moveable:GetOnCollidedWithRoom()
-
Get the name of the function called when this moveable collides with room geometry (e.g. a wall or floor)
Returns:
-
string
name of the function
- Moveable:SetOnKilled(callback)
-
Set the name of the function to be called when the moveable is destroyed/killed
Parameters:
- callback string name of function to be called
Usage:
LevelFuncs.baddyKilled = function(theBaddy) print("You killed a baddy!") end baddy:SetOnKilled("baddyKilled")
- Moveable:GetOnKilled()
-
Get the name of the function called when this moveable is killed
Returns:
-
string
name of the function
- Moveable:GetObjectID()
-
Retrieve the object ID
Returns:
-
int
a number representing the ID of the object
- Moveable:SetObjectID(ID)
-
Change the object's ID. This will literally change the object.
Parameters:
- ID ObjectID the new ID
Usage:
shiva = TEN.Objects.GetMoveableByName("shiva_60") shiva:SetObjectID(TEN.Objects.ObjID.BIGMEDI_ITEM)
- 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: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: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)
-
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 anim
- 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: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: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)
Parameters:
- HP int the amount of HP to give the moveable
- 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:GetColor()
-
Get the moveable's color
Returns:
-
Color
a copy of the 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 the table of AI bits
Usage:
local sas = TEN.Objects.GetMoveableByName("sas_enemy") sas:SetAIBits({1, 0, 0, 0, 0, 0})
- Moveable:MeshIsVisible(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 of a mesh
Returns:
-
bool
visibility status
- Moveable:ShowMesh(index)
-
Makes specified mesh visible
Use this to show specified mesh of an object.
Parameters:
- index int of a mesh
- Moveable:HideMesh(index)
-
Makes specified mesh invisible
Use this to hide specified mesh of an object.
Parameters:
- index int of a mesh
- Moveable:ShatterMesh(index)
-
Shatters specified mesh and makes it invisible
Note that you can re-enable mesh later by using ShowMesh().
Parameters:
- index int of a mesh
- Moveable:MeshIsSwapped(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 of a mesh
Returns:
-
bool
mesh swap status
- Moveable:SwapMesh(index, index, optional)
-
Set state of specified mesh swap of object
Use this to swap specified mesh of an object.
Parameters:
- index int of a slot to get meshswap from
- index int of a slot to get meshswap from
- optional int ) index of a mesh from meshswap slot to use
- Moveable:UnswapMesh(index)
-
Set state of specified mesh swap of object
Use this to bring back original unswapped mesh
Parameters:
- index int of a mesh to unswap
- Moveable:GetHitStatus()
-
Get the hit status of the object
Returns:
-
bool
true if the moveable was hit by something in the last gameplay frame, false otherwise
- Moveable:GetActive()
-
Determine whether the moveable is active or not
Returns:
-
bool
true if the moveable is active
- Moveable:GetRoom()
-
Get the current room of the object
Returns:
-
int
number representing the current room of the object
- Moveable:SetRoom(ID)
-
Set room of object
This is used in conjunction with SetPosition to teleport an item to a new room.
Parameters:
- ID int the ID of the new room
Usage:
local sas = TEN.Objects.GetMoveableByName("sas_enemy") sas:SetRoom(destinationRoom) sas:SetPosition(destinationPosition)
- Moveable:GetPosition()
-
Get the object's position
Returns:
-
Vec3
a copy of the moveable's position
- Moveable:GetJointPosition()
-
Get the object's joint position
Returns:
-
Vec3
a copy of the moveable's position
- Moveable:SetPosition(position)
-
Set the moveable's position
If you are moving a moveable whose behaviour involves knowledge of room geometry,
(e.g. a BADDY1, which uses it for pathfinding), then you must use this in conjunction
with Moveable:SetRoom. Otherwise, said moveable will not behave correctly.
Parameters:
- position Vec3 the new position of the moveable
- Moveable:GetRotation()
-
Get the moveable's rotation
Returns:
-
Rotation
a copy of the moveable's rotation
- Moveable:SetRotation(rotation)
-
Set the moveable's rotation
Parameters:
- rotation Rotation The moveable's new rotation
- Moveable:GetName()
-
Get the moveable's name (its unique string identifier)
e.g. "door_back_room" or "cracked_greek_statue"
This corresponds with the "Lua Name" field in an object's properties in Tomb Editor.
Returns:
-
string
the moveable's name
- Moveable:SetName(string)
-
Set the moveable's name (its unique string identifier)
e.g. "door_back_room" or "cracked_greek_statue"
It cannot be blank and cannot share a name with any existing object.
Parameters:
- string name the new moveable's name
Returns:
-
bool
true if we successfully set the name, false otherwise (e.g. if another object has the name already)
- Moveable:GetValid()
-
Test if the object is in a valid state (i.e. has not been destroyed through Lua or killed by Lara).
Returns:
-
valid
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-initialise it with another object.