Pikle API

0.0.1

Generated 31st May 2026, 01:50am UTC

Engine.AudioBankCount

Usage

res = Engine.AudioBankCount()

Description

Get the number of audio sound effect banks available in Pikle Player. Browse the audio effects available using the Asset Library from the Hub in Pikle Player.

Returns

number: Number of audio banks available for use

Engine.AudioBankSize

Usage

res = Engine.AudioBankSize(bankIdx)

Description

Get the number of audio samples in the specified audio bank.

Parameters

Name Type Description
bankIdxnumberBank number

Returns

number: Number of audio samples

Engine.AudioPlayOneShot

Usage

Engine.AudioPlayOneShot(slotIdx, bankIdx, sampleIdx)

Description

Play an audio sample through specified audio slot.

Parameters

Name Type Description
slotIdxnumberAudio slot index (from 0)
bankIdxnumberBank number (from 0)
sampleIdxnumberAudio sample number within bank (from 0)

Engine.AudioPlayOneShot

Usage

Engine.AudioPlayOneShot(slotIdx, bankIdx, sampleIdx, volume, pitch)

Description

Play an audio sample from the asset library at given pitch and volume. Negative pitch plays audio sample backwards. Default pitch is 1.0.

Parameters

Name Type Description
slotIdxnumberAudio slot (from 0)
bankIdxnumberBank number (from 0)
sampleIdxnumberAudio sample number (from 0)
volumenumberVolume (0.0 to 1.0)
pitchnumberPitch (-3.0 to 3.0)

Engine.Camera3DCount

Usage

res = Engine.Camera3DCount()

Description

Get number of 3D cameras

Returns

number: Camera count

Engine.Camera3DGetForward

Usage

res = Engine.Camera3DGetForward(camIdx)

Description

Get the forward facing vector of the given camera.

Parameters

Name Type Description
camIdxnumberCamera index (from 0)

Returns

table: Forward direction

Engine.Camera3DLookAt

Usage

Engine.Camera3DLookAt(camIdx, x, y, z)

Description

Set orientation of camera such that it looks at the specified world position.

Parameters

Name Type Description
camIdxnumberCamera index (from 0)
xnumberTarget position X
ynumberTarget position Y
znumberTarget position Z

Engine.Camera3DMoveForward

Usage

Engine.Camera3DMoveForward(camIdx, d)

Description

Move camera a distance along it's forward vector

Parameters

Name Type Description
camIdxnumberCamera index (from 0)
dnumberDistance to move in world units

Engine.Camera3DSetFieldOfView

Usage

Engine.Camera3DSetFieldOfView(camIdx, fov)

Description

Set the field of view of the given camera

Parameters

Name Type Description
camIdxnumberCamera index (from 0)
fovnumberField of view in degrees

Engine.Camera3DSetPosition

Usage

Engine.Camera3DSetPosition(camIdx, x, y, z)

Description

Set the position of the 3D camera

Parameters

Name Type Description
camIdxnumberCamera index (from 0)
xnumberX position
ynumberY position
znumberZ position

Engine.Camera3DSetRotation

Usage

Engine.Camera3DSetRotation(camIdx, x, y, z)

Description

Set rotation of camera

Parameters

Name Type Description
camIdxnumberCamera index (from 0)
xnumberRotation (in degrees) about X-axis
ynumberRotation (in degrees) about Y-axis
znumberRotation (in degrees) about Z-axis

Engine.DictIsWord

Usage

res = Engine.DictIsWord(word)

Description

Check if word exists in the dictionary

Parameters

Name Type Description
wordstringWord to check

Returns

boolean: True if word exists in dictionary, false otherwise

Engine.DictLoad

Usage

res = Engine.DictLoad()

Description

Load word dictionary

Returns

boolean: True if dictionary loaded successfully

Engine.DictRandomWord

Usage

res = Engine.DictRandomWord(len)

Description

Get a random word of specified length

Parameters

Name Type Description
lennumberLength of word to fetch

Returns

string: String containing word of requested length

Engine.DictUnload

Usage

Engine.DictUnload()

Description

Unload word dictionary

Engine.EnvironmentLoad

Usage

res = Engine.EnvironmentLoad(name)

Description

Load a built-in 3D environment. Current environments are:
  • Pikle City

    Parameters

    Name Type Description
    namestringName of environment to load (see list above)

    Returns

    number: Id of loaded environment

Engine.EnvironmentUnload

Usage

Engine.EnvironmentUnload(id)

Description

Unload an environment

Parameters

Name Type Description
idnumberId of environment to unload

Engine.MusicSheetCreate

Usage

res = Engine.MusicSheetCreate(sheet)

Description

EXPERIMENTAL FEATURE IN PROGRESS! Not yet optimised - playback is slower than intended! Create music sequence from 'sheet' music in given sheet string. See Music Sheet documentation for the 'sheet' format.

Parameters

Name Type Description
sheetstringString of music

Returns

number: Id of new music sheet object

Engine.MusicSheetPause

Usage

Engine.MusicSheetPause()

Description

Pause the music sheet player.

Engine.MusicSheetPlay

Usage

Engine.MusicSheetPlay(music, bpm, bank)

Description

Play music from sheet sequence created by MusicSheetCreate. All notes are selected from the specified audio bank.

Parameters

Name Type Description
musicnumberMusic Id
bpmnumberBeats per minute
banknumberBank index (from 0)

Engine.MusicSheetResume

Usage

Engine.MusicSheetResume()

Description

Resume music sheet player.

Engine.MusicSheetStop

Usage

Engine.MusicSheetStop()

Description

Stop the music player.

Engine.SetClearColor

Usage

Engine.SetClearColor(r, g, b)

Description

Set the background color. Each color component is a value between 0 and 1. White is (1, 1, 1) while black is (0,0,0).

Parameters

Name Type Description
rnumberRed
gnumberGreen
bnumberBlue

Engine.GetButtonState

Usage

res = Engine.GetButtonState(name)

Description

Get state of named button. Check if the button state is down (pressed), up (not pressed) or pressed that frame.

Parameters

Name Type Description
namestring

Returns

table: Table containing values isDown, isUp and isPressed

Engine.GetDPadState

Usage

res = Engine.GetDPadState(name)

Description

Get state of all buttons of the named dpad. Currently only DPAD0 is supported.

Parameters

Name Type Description
namestringName of dpad. Currently only DPAD0 is supported

Returns

table: State of dpad. Contains fields left, right, up and down. Each direction contains isDown, isUp and isPressed

Engine.GetJoyState

Usage

res = Engine.GetJoyState(name)

Description

Get the 2D axis of the named joystick.

Parameters

Name Type Description
namestringName of joypad, only JOY0 is supported currently. Can also be read as a dpad. Contains x, y, left, right, up and down.

Returns

table: Joystick state table with fields x, y, left, right, up and downs. x and y are between -1.0 and 1.0. left, right, down and up have isDown, isUp and iPressed

Engine.GetTouch

Usage

res = Engine.GetTouch(idx)

Description

Get the status of the given touch

Parameters

Name Type Description
idxnumberIndex of touch

Returns

table: Touch table contains fields:
state: button state table (isDown, isUp and isPressed)
x: X coordinate of touch
y: Y coordinate of touch
dx: Movement in X since last frame
dy: Movement in Y since last frame

Engine.GetTouchCount

Usage

res = Engine.GetTouchCount()

Description

Get number of touches on the touchscreen (within the Pikle screen)

Returns

number: Touch count

Engine.KeyValueGet

Usage

res = Engine.KeyValueGet(key, def)

Description

Get a string value from the persistent store. Return default value if not found.

Parameters

Name Type Description
keystringName of item (it's key)
defstringDefault string value to use if not found

Returns

string: String value of key

Engine.KeyValueGet

Usage

res = Engine.KeyValueGet(key, def)

Description

Get a number value from the persistent store. Return default value if not found.

Parameters

Name Type Description
keystringName of item (it's key)
defnumberDefault number value to use if not found

Returns

number: Number value of item or 'def' if not found

Engine.KeyValueReset

Usage

res = Engine.KeyValueReset()

Description

Remove all keys and their values

Returns

boolean: True if key store reset successfully, false otherwise

Engine.KeyValueSave

Usage

res = Engine.KeyValueSave()

Description

Save all values to persistent device storage

Returns

boolean: True if key set, false otherwise

Engine.KeyValueSet

Usage

res = Engine.KeyValueSet(key, val)

Description

Set key item to a string value

Parameters

Name Type Description
keystringItem name (it's key)
valstringString value

Returns

boolean: True if key set, false otherwise

Engine.KeyValueSet

Usage

res = Engine.KeyValueSet(key, val)

Description

Set key item to a number.

Parameters

Name Type Description
keystringItem name (it's key)
valnumber

Returns

boolean: True if key set, false otherwise

Engine.Render3DFirst

Usage

Engine.Render3DFirst()

Description

Switch to rendering 3D content on top of the 2D sprite and text layers

Engine.RenderSpriteLayersFirst

Usage

Engine.RenderSpriteLayersFirst()

Description

Switch to rendering all sprite and text layers before 3D content. 3D content will apppear on top.

Engine.SpriteLayerReset

Usage

Engine.SpriteLayerReset(idx, is3D)

Description

Reset position, orientation and mode of sprite layer. Use 3D mode to render sprites on a plane in AR mode.

Parameters

Name Type Description
idxnumberSprite layer index (starting from 0). Only 0 currently supported
is3Dbooleantrue if layer should be rendered as 3D, false for default 2D behaviour.

Engine.LEDSetChar

Usage

Engine.LEDSetChar(str)

Description

Set the LED display to an alphanumeric character (only A-Z or 0-9)

Parameters

Name Type Description
strstringFirst character of string will be displayed

Engine.LEDSetMask

Usage

Engine.LEDSetMask(mask)

Description

Set the LED display using a mask value. The lowest 25 bits of 'mask' are used. Bit 0 is the bottom-right dot. Bit 24 is the top-left dot. The following code sample displays a circle on the LED display:
Engine.LEDSetMask(bit32.bor(
    bit32.lshift(0x0E, 20),
    bit32.lshift(0x11, 15),
    bit32.lshift(0x11, 10),
    bit32.lshift(0x11, 5),
    0x0E
))

Parameters

Name Type Description
masknumberInteger mask (only lowest 25 bits used)

Engine.LightEnable

Usage

Engine.LightEnable(light, en)

Description

Enable or disable a 3D light

Parameters

Name Type Description
lightnumberIndex of light (from 0)
enbooleanTrue to enable, false to disable

Engine.LightEnableShadows

Usage

Engine.LightEnableShadows(light, enabled)

Description

Enable shadow-casting from a light

Parameters

Name Type Description
lightnumberIndex of light (from 0)
enabledbooleanTrue to cast shadows from this light, false to disable

Engine.LightOrientation

Usage

Engine.LightOrientation(light, ax, ay, az)

Description

Set the rotation of a light

Parameters

Name Type Description
lightnumberIndex (from 0) of light to rotate
axnumberAngle about x-axis (in degrees)
aynumberAngle about y-axis (in degrees)
aznumberAngle about z-axis (in degrees)

Engine.LightReset

Usage

Engine.LightReset(light)

Description

Reset a 3D light back to original white, intensity and rotation

Parameters

Name Type Description
lightnumberIndex of light (from 0)

Engine.LightSetColor

Usage

Engine.LightSetColor(light, r, g, b)

Description

Set the color of a light

Parameters

Name Type Description
lightnumberIndex of light (from 0)
rnumberRed (0.0 - 1.0)
gnumberGreen (0.0 - 1.0)
bnumberBlue (0.0 - 1.0)

Engine.LightSetIntensity

Usage

Engine.LightSetIntensity(light, intensity)

Description

Set intensity of a light

Parameters

Name Type Description
lightnumberIndex of light (from 0)
intensitynumberIntensity (default 1.0)

Engine.AngleBetween

Usage

res = Engine.AngleBetween(a, b, axis)

Description

Get the signed angle between two vectors a and b. Use axis as a reference to determine the sign of the angle.

Parameters

Name Type Description
atableVec3 vector object
btableVec3 vector object
axistableAxis reference to determine sign of angle

Returns

number: Angle between vectors (in degrees)

Engine.QuatEuler

Usage

res = Engine.QuatEuler(x, y, z)

Description

Make a quaternion using euler angles (in degrees) x, y and z

Parameters

Name Type Description
xnumberRotation about X-axis
ynumberRotation about Y-axis
znumberRotation about Z-axis

Returns

table: Quaternion

Engine.QuatMakeLookRotation

Usage

res = Engine.QuatMakeLookRotation(f, u)

Description

Make a quaternion that would cause a rotation to face target position f about up vector u

Parameters

Name Type Description
ftableTarget position
utableUp vector

Returns

table: Quaternion

Engine.QuatMultiply

Usage

res = Engine.QuatMultiply(q1, q2)

Description

Multiply two quaternions together to produce a rotation that is equivalent to q1 and q2 being applied in sequence

Parameters

Name Type Description
q1tableFirst rotation
q2tableSecond rotation

Returns

table: Rotations q1 and q2 combined into one quaternion

Engine.QuatSlerp

Usage

res = Engine.QuatSlerp(q1, q2, step)

Description

Make a quaternion that is spherically interpolated between q1 and q2 by ratio step (0.5 would be a rotation half way between the two)

Parameters

Name Type Description
q1tableStarting rotation
q2tableTarget rotation
stepnumberRatio between the two (0.0 - 1.0)

Returns

table: Interpolated quaternion between q1 and q2

Engine.RotateVector

Usage

res = Engine.RotateVector(a, axis, ang)

Description

Rotate vector a by angle ang about axis

Parameters

Name Type Description
atableVector to rotate
axistableAxis to rotate about
angnumberAngle to rotate in degrees

Returns

table: Rotated vector

Engine.Vec3Create

Usage

res = Engine.Vec3Create(x, y, z)

Description

Create a Vec3 object that has x, y and z properties.

Parameters

Name Type Description
xnumber
ynumber
znumber

Returns

table: Vector object (Vec3)

Engine.ModelCreate

Usage

res = Engine.ModelCreate(objFile, format)

Description

Create a 3D model for use with the Object functions. The 3D model must be in OBJ or PLY format (as exported from 3D applications such as Blender).

Parameters

Name Type Description
objFilestring
formatstring

Returns

number: Id of model or -1 if failed

Engine.ModelCreate

Usage

res = Engine.ModelCreate(objFile)

Description

Create a 3D model (in OBJ format) for use with the Object functions. Can use OBJ file taken directly from Blender.

Parameters

Name Type Description
objFilestring

Returns

number: Id of model or -1 if failed

Engine.ModelDestroy

Usage

Engine.ModelDestroy(id)

Description

Destroy and release memory of 3D model

Parameters

Name Type Description
idnumberId of model

Engine.ModelProcess

Usage

res = Engine.ModelProcess(id, dynFunc)

Description

Process all vertices of a model using given custom function. The user function will be called for every vertex of the model. See Stunt Car sample for example usage (modifying a 3D track mesh to fit a spline).

  • idx: Index of vertex
  • count: Number of vertices in the model
  • vertex: Table of 12 vertex elements: x, y, z

function processTrackVert(idx, count, vertex)
    -- Process vertex with index "idx"
    -- Model has "count" vertices.
    local posX, posY, posZ = v[1], v[2], v[3]
    local normalX, normalY, normalZ = v[4], v[5], v[6]
    local r, g, b, a = v[7], v[8], v[9], v[10]
    local u, v = v[11], v[12]
end

Parameters

Name Type Description
idnumberId of 3D model created with ModelCreate(..)
dynFunctableUser function to process each vertex of the 3D model

Returns

boolean: true if model created successfully

Engine.MusicBankCount

Usage

res = Engine.MusicBankCount()

Description

Get the number of banks of music currently available in Pikle Player.

Returns

number: Number of music banks

Engine.MusicPlay

Usage

Engine.MusicPlay(bank, music)

Description

Play a music track from the Asset Library. Open the Asset Library from the Pikle Player Hub to see what built-in music is available

Parameters

Name Type Description
banknumberBank number
musicnumberMusic number within bank

Engine.MusicStop

Usage

Engine.MusicStop()

Description

Stop playing music

Engine.ObjectCreate

Usage

res = Engine.ObjectCreate(bank, model)

Description

Create a 3d object that renders the built-in 3D model in asset bank. See Asset Browser in Pikle Player for built-in assets

Parameters

Name Type Description
banknumberBank number
modelnumberModel number within bank

Returns

number: Id of object

Engine.ObjectCreate

Usage

res = Engine.ObjectCreate(bank, model, x, y, z, rx, ry, rz)

Description

Create a 3D object to render a built-in model from the asset library. Give it position x,y,z and rotation rx, ry, rz

Parameters

Name Type Description
banknumberBank number
modelnumberModel number within bank
xnumberX position
ynumberY position
znumberZ position
rxnumberRotation about x-axis in degrees
rynumberRotation about y-axis in degrees
rznumberRotation about z-axis in degrees

Returns

number: Id of object

Engine.ObjectCreate

Usage

res = Engine.ObjectCreate(model, x, y, z, rx, ry, rz)

Description

Create a 3d object in world space to render the given model with rotation.

Parameters

Name Type Description
modelnumberModel id
xnumberX position
ynumberY position
znumberZ position
rxnumberRotation about x-axis
rynumberRotation about y-axis
rznumberRotation about z-axis

Returns

number: Id of object

Engine.ObjectCreateCollisionMesh

Usage

Engine.ObjectCreateCollisionMesh(obj, convex)

Description

Create a collision mesh for an object.

Parameters

Name Type Description
objnumberObject Id
convexbooleanTrue to create a convex collider, false otherwise

Engine.ObjectDestroy

Usage

Engine.ObjectDestroy(id)

Description

Destroy object and free memory

Parameters

Name Type Description
idnumberId of object to destroy

Engine.ObjectEnable

Usage

Engine.ObjectEnable(id, en)

Description

Enable or disable a 3D object. If disabled, it's model will not be rendered and the object's physics will be paused

Parameters

Name Type Description
idnumberId of object
enbooleanTrue to enable, false to disable

Engine.ObjectGetDown

Usage

res = Engine.ObjectGetDown(id)

Description

Get down-direction vector of object.

Parameters

Name Type Description
idnumberObject Id

Returns

table: Down direction vector

Engine.ObjectGetForward

Usage

res = Engine.ObjectGetForward(id)

Description

Get forward direction (local Z axis) of 3D object

Parameters

Name Type Description
idnumberObject Id

Returns

table: Forward direction vector

Engine.ObjectGetPosition

Usage

res = Engine.ObjectGetPosition(id)

Description

Get position of object

Parameters

Name Type Description
idnumberObject Id

Returns

table: World position as a Vec3

Engine.ObjectGetRight

Usage

res = Engine.ObjectGetRight(id)

Description

Get right-side direction vector (negated it represents the left)

Parameters

Name Type Description
idnumberObject Id

Returns

table: Right direction vector

Engine.ObjectGetRotation

Usage

res = Engine.ObjectGetRotation(id)

Description

Get rotation of object as euler angles in degrees.

Parameters

Name Type Description
idnumberObject Id

Returns

table: Orientation vector in degrees

Engine.ObjectGetUp

Usage

res = Engine.ObjectGetUp(id)

Description

Get up vector direction of 3D object.

Parameters

Name Type Description
idnumberObject Id

Returns

table: Up direction vector

Engine.ObjectLookat

Usage

Engine.ObjectLookat(id, x, y, z)

Description

Rotate object to face target position

Parameters

Name Type Description
idnumberObject Id
xnumberWorld target X position
ynumberWorld target Y position
znumberWorld target Z position

Engine.ObjectMove

Usage

Engine.ObjectMove(id, tx, ty, tz)

Description

Move an object by amount (tx, ty, tz)

Parameters

Name Type Description
idnumberObject Id
txnumberAmount to move in x-axis
tynumberAmount to move in y-axis
tznumberAmount to move in z-axis

Engine.ObjectMoveForward

Usage

Engine.ObjectMoveForward(id, f)

Description

Move an object a distance along it's forward vector

Parameters

Name Type Description
idnumberObject Id
fnumberAmount to move

Engine.ObjectSetColor

Usage

Engine.ObjectSetColor(id, r, g, b)

Description

Set the color of an individual object

Parameters

Name Type Description
idnumberObject Id
rnumberRed (0.0 - 1.0)
gnumberGreen (0.0 - 1.0)
bnumberBlue (0.0 - 1.0)

Engine.ObjectSetPosition

Usage

Engine.ObjectSetPosition(id, tx, ty, tz)

Description

Set the world position of an object

Parameters

Name Type Description
idnumberObject Id
txnumberX position
tynumberY position
tznumberZ position

Engine.ObjectSetRotation

Usage

Engine.ObjectSetRotation(id, r)

Description

Set rotation of an object using a quaternion

Parameters

Name Type Description
idnumberObject Id
rtableRotation to be applied

Engine.ObjectSetRotation

Usage

Engine.ObjectSetRotation(id, rx, ry, rz)

Description

Set rotation of an object

Parameters

Name Type Description
idnumberObject Id
rxnumberRotation in degrees aout x-axis
rynumberRotation in degrees aout y-axis
rznumberRotation in degrees aout z-axis

Engine.ObjectSetScale

Usage

Engine.ObjectSetScale(id, sx, sy, sz)

Description

Set scale of an object

Parameters

Name Type Description
idnumberObject Id
sxnumberX scale
synumberY scale
sznumberZ scale

Engine.ObjectSetTexture

Usage

Engine.ObjectSetTexture(id, bank, asset)

Description

Change the texture of the object to the texture from the sprite bank

Parameters

Name Type Description
idnumberObject Id
banknumberBank number
assetnumberAsset number with bank

Engine.ObjectSetVisible

Usage

Engine.ObjectSetVisible(id, vis)

Description

Set visibility of the 3D model

Parameters

Name Type Description
idnumberId of object
visbooleanTrue if visible, false otherwise

Engine.RaycastPoll

Usage

res = Engine.RaycastPoll(requestId)

Description

Check for a raycast result. Result (table) contains the following properties:
px, py, pz: world space position of hit
nx, ny, nz: normal vector of surface hit by ray
distance: distance from ray start to hit location

Parameters

Name Type Description
requestIdnumber

Returns

table: Hit result of type RaycastResult (see above)

Engine.RaycastRequest

Usage

res = Engine.RaycastRequest(ray)

Description

Request a raycast. A ray will be sent through the scene to see if any collidable objects are found. Objects without a collision mesh will not be found. Result is NOT available immediately. You must check for a result using RaycastPoll. Ray table contains:
px, py, pz: start position of ray
rx, ry, rz: ray direction
maxDistance: distance to shoot the ray (objects won't be detected beyond this distance)

Parameters

Name Type Description
raytableRay information (see above)

Returns

number: Id of request

Engine.ScriptGetCount

Usage

res = Engine.ScriptGetCount()

Description

Return the number of scripts on this device.

Returns

number: Total script count (built-in samples + user scripts)

Engine.ScriptGetName

Usage

res = Engine.ScriptGetName(idx)

Description

Get the name of the script with the given index number.

Parameters

Name Type Description
idxnumberIndex of script. First script is at index 1.

Returns

string: Name (string) of script

Engine.ScriptIsUserFile

Usage

res = Engine.ScriptIsUserFile(idx)

Description

Return true if the script at index 'idx' is a user script or a builtin script.

Parameters

Name Type Description
idxnumberIndex (first script is at index 1)

Returns

boolean: true if user script, false otherwise

Engine.ScriptRun

Usage

Engine.ScriptRun(idx)

Description

Launch script with given index 'idx'. Warning: active script will be lost if not saved.

Parameters

Name Type Description
idxnumberIndex of script (starting at 1)

Engine.SpriteAnimateAll

Usage

Engine.SpriteAnimateAll(dt)

Description

Make all sprite animation

Parameters

Name Type Description
dtnumberAmount of time to a

Engine.SpriteColor

Usage

Engine.SpriteColor(idx, r, g, b, a)

Description

Set the color of a sprite

Parameters

Name Type Description
idxnumberIndex of sprite (0 to 255)
rnumberRed (0.0 to 1.0)
gnumberGreen (0.0 to 1.0)
bnumberBlue (0.0 - 1.0)
anumberAlpha (0.0 - 1.0) where 0.0 is transparent and 1.0 is opaque

Engine.SpriteCreateAnim

Usage

res = Engine.SpriteCreateAnim(duration, frames)

Description

Create a sprite animation with a duration and a number of frames (images). Each frame specifies an images bank and shape number. A two-frame animation [0, 10, 1, 20] uses two images, shape 10 from bank 0 and shape 20 from bank 1.

Parameters

Name Type Description
durationnumberDuration in seconds
framestableArray of frame data.

Returns

number: Id of sprite animation

Engine.SpriteDestroyAnim

Usage

Engine.SpriteDestroyAnim(id)

Description

Destroy and release instance of sprite animation.

Parameters

Name Type Description
idnumberId of animation created using SpriteCreateAnim

Engine.SpriteEnable

Usage

Engine.SpriteEnable(idx, en)

Description

Enable or disable a single sprite.

Parameters

Name Type Description
idxnumberIndex of sprite to enable/disable (0 to 255)
enbooleantrue to enable, false to disable

Engine.SpriteEnableAll

Usage

Engine.SpriteEnableAll(en)

Description

Enable or disable all 256 sprites (0 to 255).

Parameters

Name Type Description
enbooleanTrue to enable, false to disable

Engine.SpriteFontCreate

Usage

res = Engine.SpriteFontCreate(fontDef)

Description

Create a font using sprites. In the asset library there are sprites of alphanumeric characters. These can be used to display words, numbers and phrases. Each letter is a sprite. Sprite fonts are described using a table with the following properties:
spriteBank: Bank index number (starting from 0)
a: Sprite index to use for the letter 'a' (remaining lowercase letters to follow in sequence)
A: Sprite index to use for the uppercase letter 'A' (remaining uppercase letters to follow in sequence)
Zero: Sprite index for the digit '0' (remaining digits will follow in sequence)
Kerning: Number to adjust the spacing between sprites
Size: Sprite scale will be set to this size

Parameters

Name Type Description
fontDeftableFont description that controls how sprites are positioned

Returns

number: Id of new sprite font

Engine.SpriteFontLabel

Usage

res = Engine.SpriteFontLabel(fontId, firstSpr, label, x, y, z)

Description

Display a text label using sprites based on the provided font description.

Parameters

Name Type Description
fontIdnumberFont id as returned from SpriteFontCreate
firstSprnumberIndex of sprite to use for the first character (subsequent characters will use sprite indices in order)
labelstringAlphanumeric text to display
xnumberX position
ynumberY position
znumberZ position (used for ordering only)

Returns

number: Number of sprites used

Engine.SpriteGetPosition

Usage

res = Engine.SpriteGetPosition(idx)

Description

Get 3D position of sprite

Parameters

Name Type Description
idxnumberIndex of sprite (0 to 255)

Returns

table: Position of sprite in world space

Engine.SpriteGroupAllocSprite

Usage

res = Engine.SpriteGroupAllocSprite(grpId)

Description

Get an unused sprite from the sprite group.

Parameters

Name Type Description
grpIdnumberGroup Id

Returns

number: Index of sprite

Engine.SpriteGroupCreate

Usage

res = Engine.SpriteGroupCreate(min, count)

Description

Create a sprite group.

Parameters

Name Type Description
minnumberIndex of first sprite
countnumberNumber of sprites in the group

Returns

number: Id of sprite group

Engine.SpriteGroupDestroy

Usage

Engine.SpriteGroupDestroy(grpId)

Description

Destroy the group. This does not affect the sprites in the group, it just releases the object from memory.

Parameters

Name Type Description
grpIdnumberGroup Id

Engine.SpriteGroupEnable

Usage

Engine.SpriteGroupEnable(grpId, en)

Description

Enable or disable all sprites in the group

Parameters

Name Type Description
grpIdnumberGroup Id
enbooleanTrue to enable all sprites, false to disable all sprites

Engine.SpriteGroupFreeAllSprites

Usage

Engine.SpriteGroupFreeAllSprites(grpId)

Description

Mark all sprites in the group as unused.

Parameters

Name Type Description
grpIdnumberGroup Id

Engine.SpriteGroupFreeSprite

Usage

Engine.SpriteGroupFreeSprite(grpId, sprId)

Description

Mark a sprite in the group as unused. Once unused, it can be allocated again via SpriteGroupAllocSprite.

Parameters

Name Type Description
grpIdnumberGroup Id
sprIdnumberSprite id to mark as unused

Engine.SpriteGroupMovePosition

Usage

Engine.SpriteGroupMovePosition(grpId, dx, dy, dz)

Description

Move the position of all sprites by (dx,dy,dz).

Parameters

Name Type Description
grpIdnumberGroup Id
dxnumberChange in X position
dynumberChange in Y position
dznumberChange in Z position

Engine.SpriteGroupSetColor

Usage

Engine.SpriteGroupSetColor(grpId, r, g, b, a)

Description

Set the color of all sprites in a sprite group.

Parameters

Name Type Description
grpIdnumberGroup Id
rnumberRed (0.0 - 1.0)
gnumberGreen (0.0 - 1.0)
bnumberBlue (0.0 - 1.0)
anumberAlpha (0.0 - 1.0)

Engine.SpriteGroupSetPosition

Usage

Engine.SpriteGroupSetPosition(grpId, x, y, z)

Description

Set the position of all sprites in the group to the same (x,y,z). (0,0,0) is the center of the screen.

Parameters

Name Type Description
grpIdnumberGroup Id
xnumberX position
ynumberY position
znumberZ position

Engine.SpriteGroupSetScale

Usage

Engine.SpriteGroupSetScale(grpId, sx, sy, sz)

Description

Set the scale of all sprites in the group to (sx,sy,sz). (1,1,1) is default scale.

Parameters

Name Type Description
grpIdnumberGroup Id
sxnumberX scale
synumberY scale
sznumberZ scale

Engine.SpriteGroupSetShape

Usage

Engine.SpriteGroupSetShape(grpId, bank, spr)

Description

Set all sprites in the group to the same image from the asset library

Parameters

Name Type Description
grpIdnumberGroup Id
banknumberSprite image bank index (from 0)
sprnumberSprite asset index (from 0)

Engine.SpriteGroupSetSortingOrder

Usage

Engine.SpriteGroupSetSortingOrder(grpId, order)

Description

Set sorting order of all sprites in a sprite group. Higher order sprites are drawn on top of lower order sprites.

Parameters

Name Type Description
grpIdnumberGroup Id
ordernumberRendering order

Engine.SpriteIsColliding

Usage

res = Engine.SpriteIsColliding(idx1, idx2)

Description

Check if the bounds of two sprites are overlapping.

Parameters

Name Type Description
idx1numberFirst sprite index (0 to 255)
idx2numberSecond sprite index (0 to 255)

Returns

boolean: true if colliding, false otherwise

Engine.SpriteIsEnabled

Usage

res = Engine.SpriteIsEnabled(idx)

Description

Check if a sprite is enabled

Parameters

Name Type Description
idxnumberIndex of sprite (0 to 255)

Returns

boolean: true if enabled, false otherwise

Engine.SpriteLayerLocalRotation

Usage

Engine.SpriteLayerLocalRotation(layer, rx, ry, rz)

Description

Set local rotation of sprite layer (rotation in degrees). Does not take affect until end of frame.

Parameters

Name Type Description
layernumberLayer number starting from 0. [Only 0 supported currently]
rxnumberRotation about X-axis
rynumberRotation about Y-axis
rznumberRotation about Z-axis

Engine.SpriteLayerLocalScale

Usage

Engine.SpriteLayerLocalScale(layer, sx, sy, sz)

Description

Set scale of sprite layer. Does not take affect until frame is rendered.

Parameters

Name Type Description
layernumberLayer number starting from 0 [Only 0 supported currently]
sxnumberScale in X axis
synumberScale in Y axis
sznumberScale in Z axis

Engine.SpriteLayerRotate

Usage

Engine.SpriteLayerRotate(layer, world, rx, ry, rz)

Description

Rotate sprite layer (rotation in degrees)

Parameters

Name Type Description
layernumberLayer number starting from 0 [Only 0 supported currently]
worldbooleantrue to rotate about world axis, false to rotate around local axis
rxnumberRotation about X-axis
rynumberRotation about Y-axis
rznumberRotation about Z-axis

Engine.SpriteMove

Usage

Engine.SpriteMove(idx, dx, dy, dz)

Description

Move a sprite

Parameters

Name Type Description
idxnumberIndex of sprite (0 to 255)
dxnumberAmount to move in X direction
dynumberAmount to move in Y direction
dznumberAmount to move in Z direction

Engine.SpriteOrder

Usage

Engine.SpriteOrder(idx, order)

Description

Set order of sprite within it's sprite layer. Use high order number to render a sprite on top of lower-ordered sprites.

Parameters

Name Type Description
idxnumberIndex of sprite (0 to 255)
ordernumberOrder number (use high order number to render sprite on top)

Engine.SpritePlayAnim

Usage

Engine.SpritePlayAnim(sprId, restart)

Description

Start playing sprite animation on sprite

Parameters

Name Type Description
sprIdnumberSprite index (0 to 255)
restartbooleantrue if animation should start from the beginning

Engine.SpritePosition

Usage

Engine.SpritePosition(idx, x, y, z)

Description

Set position of sprite

Parameters

Name Type Description
idxnumberIndex of sprite (0 to 255)
xnumberX position
ynumberY position
znumberZ position

Engine.SpriteRotation

Usage

Engine.SpriteRotation(idx, x, y, z)

Description

Set rotation (in degrees) of sprite

Parameters

Name Type Description
idxnumberIndex of sprite (0 to 255)
xnumberX rotation
ynumberY rotation
znumberZ rotation

Engine.SpriteScale

Usage

Engine.SpriteScale(idx, x, y, z)

Description

Set scale of sprite

Parameters

Name Type Description
idxnumberIndex of sprite (0 to 255)
xnumberX scale
ynumberY scale
znumberZ scale

Engine.SpriteSetAnim

Usage

Engine.SpriteSetAnim(sprId, animId, loop)

Description

Set sprite to use animation created with SpriteCreateAnim

Parameters

Name Type Description
sprIdnumberSprite index (0 to 255)
animIdnumberId of animation
loopbooleantrue if animation should loop

Engine.SpriteSetAnim

Usage

Engine.SpriteSetAnim(sprId, animId, play, loop)

Description

Set sprite to use animation created with SpriteCreateAnim

Parameters

Name Type Description
sprIdnumberSprite index (0 to 255)
animIdnumberId of animation
playbooleantrue if animation should start playing immediately
loopbooleantrue if animation should loop

Engine.SpriteSetAnimLoop

Usage

Engine.SpriteSetAnimLoop(sprId, loop)

Description

Set sprite to loop it's animation

Parameters

Name Type Description
sprIdnumberSprite index (0 to 255)
loopbooleantrue if animation should loop, false otherwise

Engine.SpriteShape

Usage

Engine.SpriteShape(idx, bank, shape)

Description

Set sprite image

Parameters

Name Type Description
idxnumberIndex of sprite (0 to 255)
banknumberBank number (from 0)
shapenumberShape number (from 0)

Engine.SpriteShape

Usage

Engine.SpriteShape(idx, shape)

Description

Set sprite image without changing bank number.

Parameters

Name Type Description
idxnumberIndex of sprite (0 to 255)
shapenumberShape index from 0

Engine.APIVersion

Usage

res = Engine.APIVersion()

Description

Get the API version.

Returns

string: Version string in format Major.Minor.Patch (e.g. 0.0.1)

Engine.Reset

Usage

Engine.Reset()

Description

Reset engine state back to defaults. Clears all sprites and other engine objects.

Engine.ClearText

Usage

Engine.ClearText()

Description

Clear the fixed-width text layer.

Engine.NumTextColumns

Usage

res = Engine.NumTextColumns()

Description

Get the number of columns in the fixed-width text layer

Returns

number: Column count

Engine.NumTextRows

Usage

res = Engine.NumTextRows()

Description

Get the number of rows in the fixed-width text layer

Returns

number: Row count

Engine.SetCursorPosition

Usage

Engine.SetCursorPosition(x, y)

Description

Set the position of the cursor on the fixed-width text layer. Top-left of screen is at (0,0).

Parameters

Name Type Description
xnumberInteger value between 0 and GetTextColumns()-1
ynumberInteger value between 0 and GetTextRows()-1

Engine.SetTextColor

Usage

Engine.SetTextColor(r, g, b, a)

Description

Set the color of the fixed-width text layer. Each color component is a value between 0 and 1. White is (1, 1, 1) while black is (0,0,0). Alpha value a is 0 for transparent, 1 for solid.

Parameters

Name Type Description
rnumberRed
gnumberGreen
bnumberBlue
anumberAlpha

Engine.Text

Usage

Engine.Text(t)

Description

Draw text t at current cursor position.

Parameters

Name Type Description
tstringText string

Engine.Text

Usage

Engine.Text(col, row, t)

Description

Draw some text t at position (x,y).

Parameters

Name Type Description
colnumberInteger column value
rownumberInteger row value
tstringString text

Engine.TextClear

Usage

Engine.TextClear()

Description

Clear the fixed-width text layer.

Engine.TextNumColumns

Usage

res = Engine.TextNumColumns()

Description

Get the number of columns in the fixed-width text layer

Returns

number: Column count

Engine.TextNumRows

Usage

res = Engine.TextNumRows()

Description

Get the number of rows in the fixed-width text layer

Returns

number: Row count

Engine.TextOrder

Usage

Engine.TextOrder(order)

Description

Set the rendering order of the fixed-width text layer. Determines whether other items such as sprites will be rendered on top or underneath.

Parameters

Name Type Description
ordernumberInteger value of order

Engine.TextSetColor

Usage

Engine.TextSetColor(r, g, b, a)

Description

Set the color of the fixed-width text layer. Each color component is a value between 0 and 1. White is (1, 1, 1) while black is (0,0,0). Alpha value a is 0 for transparent, 1 for solid.

Parameters

Name Type Description
rnumberRed
gnumberGreen
bnumberBlue
anumberAlpha

Engine.TextSetCursorPosition

Usage

Engine.TextSetCursorPosition(x, y)

Description

Set the position of the cursor on the fixed-width text layer. Top-left of screen is at (0,0).

Parameters

Name Type Description
xnumberInteger value between 0 and GetTextColumns()-1
ynumberInteger value between 0 and GetTextRows()-1

Engine.TileCellSize

Usage

Engine.TileCellSize(layer, w, h)

Description

Set cell size of tile layer

Parameters

Name Type Description
layernumberLayer id (only 0 currently supported)
wnumberWidth in pixels
hnumberHeight in pixels

Engine.TileClear

Usage

Engine.TileClear(layer, x, y)

Description

Clear tile at specific location

Parameters

Name Type Description
layernumberLayer id
xnumberColumn index
ynumberRow index

Engine.TileClearLayer

Usage

Engine.TileClearLayer(layer)

Description

Clear all tiles from a tile layer

Parameters

Name Type Description
layernumber

Engine.TileEnable

Usage

Engine.TileEnable(en)

Description

Enable or disable tile layering system

Parameters

Name Type Description
enboolean

Engine.TileLayerEnable

Usage

Engine.TileLayerEnable(layer, en)

Description

Enable or disable individual tile layer

Parameters

Name Type Description
layernumberLayer id (only 0 supported)
enbooleantrue to enable layer, false to disable the layer

Engine.TileSet

Usage

Engine.TileSet(layer, x, y, bank, tile)

Description

Set a tile on the tile layer

Parameters

Name Type Description
layernumberLayer id
xnumberTile position (column)
ynumberTile position (row)
banknumberBank location for tile image
tilenumberIndex of tile (0=empty space)

Engine.TileSetBlock

Usage

Engine.TileSetBlock(layer, x, y, sizeX, sizeY, palette, tileBlock)

Description

Set a block of tiles at once

Parameters

Name Type Description
layernumberLayer id
xnumberColumn position in tile map
ynumberRow position in tile map
sizeXnumberHorizontal size of block
sizeYnumberVertical size of block
palettenumberBank index
tileBlocktableArray if tile indices

Engine.TileSetLayerScale

Usage

Engine.TileSetLayerScale(layer, scale)

Description

Set scale of a tile layer

Parameters

Name Type Description
layernumberLayer id
scalenumberScale (1.0 = normal)

Engine.TileSetTileColor

Usage

Engine.TileSetTileColor(layer, x, y, r, g, b, a)

Description

Set color of an individual tile

Parameters

Name Type Description
layernumberLayer id
xnumberColumn position
ynumberRow position
rnumberRed (0.0 - 1.0)
gnumberGreen (0.0 - 1.0)
bnumberBlue (0.0 - 1.0)
anumberAlpha (0.0 - 1.0)

Engine.TileSetTileScale

Usage

Engine.TileSetTileScale(layer, x, y, scaleX, scaleY, scaleZ)

Description

Set the scale of a single tile

Parameters

Name Type Description
layernumberLayer id
xnumberColumn position
ynumberRow position
scaleXnumberScale in X-axis
scaleYnumberScale in Y-axis
scaleZnumberScale in Z-axis

Engine.TileSortingOrder

Usage

Engine.TileSortingOrder(layer, order)

Description

Set sorting order of individual tile layer (affects which layers render on top of other layers)

Parameters

Name Type Description
layernumberLayer id
ordernumberRender order

Engine.GameTime

Usage

res = Engine.GameTime()

Description

Get current game running time in seconds (starts at 0.0)

Returns

number: Time (age) of game in seconds

Engine.TimeStep

Usage

res = Engine.TimeStep()

Description

Get time elapsed since last frame.

Returns

number: Elapsed time in seconds