TombEngine 1.3 scripting interface
Welcome to the TombEngine scripting API. This is a work in progress and some information might be wrong or outdated. Please also note that this is primarily a reference document, not a tutorial, so expect descriptions to be fairly sparse.
At the time of writing, there is a tutorial describing the basics of Lua, as well as a number of example scripts, on the TombEngine website.
Module Hierarchy (boring but important)
Other than the "special tables" (GameVars, LevelVars and LevelFuncs), every module described herein is held in a master table called TEN. For convenience, these modules and classes are automatically put in the global table. For example, you can call GetMoveableByName either of these two ways:
local door = TEN.Objects.GetMoveableByName("door_type4_14")
local door = GetMoveableByName("door_type4_14")
Always check logs/TENLog.txt
If you are scripting levels, TombEngine will often kick you back to the title screen, even if
errorMode (see Flow.Settings) is set to
This might get annoying, but it's on purpose. If your Lua script contains a syntax error (e.g. you're missing
end at the end of a function), the Lua interpreter will not be able to continue running the script. If it tried to keep running, you'd probably see some pretty strange behaviour, and would possibly get a crash regardless.
If this happens, check logs/TENLog.txt and look for an error message with the word "unrecoverable".
|Functions to generate effects.
|Functions that (mostly) don't directly impact in-game mechanics.
|Functions for input management.
|Saving data, triggering functions, and callbacks for level-specific scripts.
|Moveables, statics, cameras, and so on.
|Functions for sound management.
|Utility functions for various calculations.
|Functions to manage camera and game view.
|Represents a display sprite.
|New custom animations which Lara can perform.
|Represents the properties of an object as it appears in the inventory.
|Stores level metadata.
|A mirror effect.
|Settings that will be run on game startup.
|Describes a layer of moving clouds.
|Basic cameras that can point at Lara or at a CAMERA_TARGET.
|Class for extra Lara-only functions.
|Represents any object inside the game world.
|A string appearing on the screen.
3 Primitive Classes
|An RGBA or RGB color.
|Represents a degree-based 3D rotation.
|Represents a float-based 2D vector.
|Represents a float-based 3D vector.
|Constants for blend mode IDs.
|Constants for effect IDs.
|Constants for game statuses.
|Constants for action key IDs.
|Constants for player weapon ammo types.
|Constants for moveable statuses.
|Constants for object IDs.
|Constants for room flag IDs.
|Constants for room reverb types.
|Constants for the type of the audio tracks.
|Constants for LogLevel IDs.
|Constants for sprite align modes.
|Constants for the type of the Camera.
|Constants for the post-process effects to apply.
|Constants for scale modes.
5 Lua utility modules
|Event sequence - a chain of functions to call at specified times, modeled after TRNG's organizers.
|Basic timer - after a specified number of seconds, the specified thing happens.