-
Notifications
You must be signed in to change notification settings - Fork 3
Lua API
tiffany352 edited this page Oct 19, 2012
·
6 revisions
Each table in the API consists of:
- A
create
method, which will create a new version of that object. - Objects are tables that have
__index
set to the table of that type, and contain only 2 fields (ptr
andtype
), related to implementation. - The table contains a function called
getType()
which returns the name of the type as a string. - The table contains a function called
isA()
which will return true if the object is or inherets directly or indirectly from the given string type. - The table's
__call
is set tocreate
Any additions to the table are noted in the documentation for that type.
Table name: script
-
script:fromSource(source)
- Loads a script from the provided source string. -
script:fromFile(file)
- Loads a script from the provided file name. -
script:run()
- Runs a script in its own Lua state.
Table name: vector2
- Metamethods in each instance:
__tostring
,__add
,__sub
,__mul
,__div
,__index
,__newindex
. - Values in each instance:
x
,y
,len
,normal
. -
vector2:dot(vec)
- Computes the dot product of the two supplied vectors.
Table name: vector3
- Same as Vector2, but has additional members:
- Values in each instance:
z
. -
vector3:cross(vec)
- Computes the cross product of the two supplied vectors.
Table name: vector4
- Same as Vector3, but has additional members:
- Values in each instance:
w
.
Table name: quaternion
- Metamethods in each instance:
__index
,__newindex
,__mul
. - Values in each instance:
x
,y
,z
,w
. -
quaternion:fromAxisAngle(vec, a)
orquaternion:fromAxisAngles(x, y, z, a)
- Creates a new quaternion from an axis to rotate around (normal represented byvec
) and an angle to rotate by (a
). -
quaternion:fromYPR(y, p, r)
- Creates a new quaternion using Yaw, Pitch, and Roll values.
Table name: positionable
- Metamethods in each instance:
__index
,__newindex
. - Values in each instance:
position
,rotation
,size
,velocity
,parent
.
Table name: world
local s = script();
s:fromFile("test.lua");
s:run();