Engine and modding documentation

Back to readme


Level editor

To use the level editor: press A in-game and then click on the right-top menu. Use directional keys and page up / page down to move cursor. Save with 'S', and backup you .dat files regularly.

Note: the generation procedures (in "Generate landscapes" menu) use the current cube type to create earth and the next cube type to create ground. For example, if the current cube type is 2, it uses 2 for earth and 3 for ground. Do not generate landscapes if the last cube type is selected!


Script basics

The script is using the lua programming language. To modify the script, open the file world.lua with a text editor like notepad or Notepad++.

To setup the game, you must create a lua table named "Game" with the following methods:

To create an active object, you must create a table with the following methods, and then add the name of this table in the initActiveObjects(...) call:


Script API

All Lua standard libraries are available. The new additional available functions are as follow:

Misc:

Math and utilities

Sound

Current active object interaction. These functions shall be called only in the methods of the object.

Player and camera interaction

'Global' variables:

These variables are managed by the engine, and are accessed in the script through the functions setGlobalVar, getGlobalVar, and addToGlobalVar. These variables are saved when the game is saved.

Text:

2D sprites:

3D models:

Cube and object creation and cube collision functions

Interactions with the game configuration. These functions allows you to change the values loaded from world.xml during the game execution. Notes:


Import 3D meshes

With 3DsMax

Export as OBJ

(img1) (img2)

Then in the world.lua file:

--init variable model3D
model3D = 0

--load the model into memory
function lua_load_0()
	model3D = load3DModel('my_object.obj')
end

--do object-related things
function lua_manage_0()
end

--draw the model
function lua_draw_0()
	draw3DModel(model3D)
end

--free the model from memory
function lua_unload_0()
	unload3DModel(model3D)
end

Then increment the return value of lua_getNbObjects() of one:

function lua_getNbObjects()
	return 1
end

Then add the object into the game editor, pressing 'x' key.

Note: if you have several objects of the same type '0' in the game, the function lua_load_0 is called once, when any of these objects is being visible, i.e. not hidden by the fog. The function lua_unload_0 is called when no more object is visible.


Config file

Some elements of the game are configured in world.xml.

Program command line arguments

Application.exe takes the following parameters: