Documentation

Lua Scripting (^)

I won't provide a general lua documentation. You can find that on the official lua homepage.
There are two namespaces at the moment: map and player. You access the elements in those namespaces with map.element.

Map Functions (^)

map.acid( x, y )

Acids wall-tiles around x/y, but not x/y itself.

Example:

map.acid( 10, 10 ) -- Will acid at 9,9; 9,10; 9,11; 10,9; 10,11; 11,9; 11,10; 11,11

map.CreateObject( objname, x, y )

Creates the object objname at x/y.

Example:

map.CreateObject( "acid", 10, 10 ) -- Will create a acid-potion at 10,10

map.CreateRobot( x, y )

Creates a robot at x/y.

Example:

map.CreateRobot( 10, 10 ) -- Will create a robot at 10,10

map.GetRandomFreePosition( )

Returns a new table with x/y coordinates of a random, free(=walkable) position on the map.

Example:

pos = map.GetRandomFreePosition( ) map.CreateRobot( pos.x, pos.y ) -- Will create a robot at a random, free position.

map.CheckTile( x, y, mask )

Checks if map-tile on x, y conforms with mask.
Values for mask:
WALL1
WALKABLE2
PUSHABLE4
EFENCE8
SLOW16
NOTPUSHABLE32
SOLID64

Example:

if map.CheckTile( 10, 10, 2) then map.CreateObject( "acid", 10, 10 ) end -- will create an acid-potion on 10,10 only if the map-tile is WALKABLE

map.IsObjectOn( x, y )

Checks whether there is an object on x/y or not.

Example:

map.CreateObject( "acid", 10, 10 ) map.IsObjectOn( 10, 10 ) -- true

map.IsRobotOn( x, y )

Checks whether there is an robot on x/y or not.

Example:

map.CreateRobot( 10, 10 ) map.IsRobotOn( 10, 10 ) -- true

map.CheckFree( x, y )

Checks if the position on x/y is free.
That's the case when:

  1. No Object is on x/y
  2. No Robot is on x/y
  3. The Tile has the attribute WALKABLE

Player Functions (^)

player.getPosition( )

Returns a table with the following attributes:
x x position
y y position

Example:

pos = player.getPosition() map.acid( pos.x, pos.y ) -- acids around player

player.setImmune( state )

Sets the Player's electronic-fence immunity to state. (And swaps images)

Example:

player.setImmune( true ) -- Player is now immune

player.addLives( num = 1 )

Adds num lives. (Standard = 1)

Example:

player.addLives( ) -- adds one live player.addLives( 3 ) -- adds 3 lives

player.teleport( x, y )

Sets the new position of the player to x/y

player.pickup( obj )

Picks obj up, where obj is lightuserdata - a C-pointer to an object class.

Objects (^)

Definition

Objects are defined in the file objects.lua.
Objects are tables which are stored with an unique key in the main objects table.

Example:

object["identifier"] = { Properties }

Properties are one of those:
PropertyPossible ValuesDescription
tileintGraphic tile in objects.png tilefile. -1 = invisible
nuseOnce, Multi, DropTimes the Object can be used. Drop means that the object cannot be used but is dropped instead

Example:

objects["acid"] = -- new object "acid" { tile = 0, -- With tile-id 0 nuse = "Once", -- Only useable once }

Callbacks

Callbacks are functions that are called when something special happens with the object (see list below).

Example:

function object.name.Callback( obj ) --function stuff end

There are the following Callbacks:
CallbackDescription
Activation( obj )Called when the object is used. obj stores an C-Pointer to the object.
PlayerOnTile( obj )Called when the player walks on the tile. obj stores an C-Pointer to the object.
Pickup( obj )Called when the object is picked up. obj stores an C-Pointer to the object.
Drop( obj )Called when the object is dropped. obj stores an C-Pointer to the object.

Example:

function objects.acid.Activation( obj ) pos = player.getPosition(); map.acid( pos.x, pos.y ); end

map.txt (^)

Work in progress