LuaScript | |
ID | 184 |
---|---|
Category | Tools/effects |
Sublayer width | 14 |
Scriptable object, write your own Lua programs that can interact with and control the level. This allows for more complex creations and games, being able to draw arbitrary graphics and more.
Lua is a small programming language that focuses on being easily embeddable within other programs. You may have stumbled upon it being used somewhere else. Every program implements its own API on top of the Lua standard library, including Principia. Don't expect any non-standard Lua standard library extensions provided in other programs to necessarily exist in Principia.
Principia uses Lua version 5.2, so any generic tutorials for Lua 5.2 should apply to Principia as well. For general information about the programming language see the Lua 5.2 Reference Manual.
For help with Lua you can ask either in the #lua
channel in the Principia Discord or in the Lua forum.
The following built-in libraries are available in the Principia Lua environment:
math
string
(older versions require a flag to be enabled)table
(older versions require a flag to be enabled)bitop32
(1.5.2+)In addition to the reference, you can see LuaScript/Examples for small complete examples that use the API.
this
: Reference to the unique LuaScript object itself, with methods that relate to the current LuaScript object.game
: Global object containing game related methods.cam
: Global object containing camera related methods.world
: Global object containing world related methods.entity
: Reference to a Principia game object, which can be retrieved using world:get_entity()
.creature
: Extension of the entity
class for living objects such as robots.