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.


World generation

In "Generate landscapes" menu. It uses the file world_groundmap.png which sets the lower point of the column of cubes, and the file world_heightmap.png which sets its upper point (this means that if world_groundmap.png is not black, you can do floating islands). If the file world_heightmap.png have colors, it selects different cube types for different pixels:


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 init(), uninit(), manage() and draw() of an 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 creation and collision functions

Object creation functions

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

Pathfinding


Import 3D meshes

With 3DsMax

Export as OBJ

(img1) (img2)

Then in the world.lua file:

MyObject = {

	model3D = 0,
	
	--load the model into memory
	load = function()
		model3D = load3DModel('models/obj_my_object/my_object.obj')
	end,

	--do object-related things
	manage = function()
	end,

	--draw the model

	draw = function()
		draw3DModel(model3D)
	end,
	
	--free the model from memory
	unload = function()
		unload3DModel(model3D)
	end
}

Then add in initActiveObjects() call in Game->init function :

initActiveObjects("MyObject")

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

Note: if you have several objects of the same type, for example '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:

On Windows, edit the .bat files to change it.

Note: to print benchmark in the console: press '*' in game