Krig Game Engine
Functions
api_level.cpp File Reference

Krig Game Engine Lua Scripting API - Game Level. More...

Functions

void load (string)
 
void load_from_buffer (string)
 
void pause ()
 
int get_id ()
 
int set_id (int)
 
void swap ()
 
bool get_complete ()
 
void set_complete (bool)
 
void play_music (string, int)
 
void stop_music ()
 
void pause_music ()
 
void set_sky_box (float, float, float, float, float, float, float, float, float)
 
Vector get_light_direction ()
 
void set_light_direction (Vector)
 
void set_light_direction (float, float, float)
 
void set_terrain (TerrainObjectReference, string)
 
int get_camera_id ()
 
GameObjectReference find_object_of_type (int)
 
GameObjectReference add_object (string, options)
 
void remove_object (GameObjectReference)
 
TextObjectReference add_text (string, string, options)
 
TextObjectReference add_sprite (string, options)
 
int luaopen_krigLevel (lua_State *L)
 

Detailed Description

Krig Game Engine Lua Scripting API - Game Level.

Game level API functionality.

Function Documentation

◆ add_object()

GameObjectReference add_object ( string  ,
options   
)

Add a game object to the current level.

Parameters
string- path to lua script for new game object to load.
table- options table to be passed into the "on_load" method for the game object.
Returns
GameObjectReference

◆ add_sprite()

TextObjectReference add_sprite ( string  ,
options   
)

Add a 2D bitmapped game object to the current level.

Parameters
string- path to lua script for new object to load.
table- options table to be passed into the "on_load" method for the object.
Returns
TextObjectReference

◆ add_text()

TextObjectReference add_text ( string  ,
string  ,
options   
)

Add a game object to the current level.

Parameters
string- path to lua script for new text object to load.
string- text.
table- options table to be passed into the "on_load" method for the text object.
Returns
TextObjectReference

◆ find_object_of_type()

GameObjectReference find_object_of_type ( int  )

Query the engine for a game object of the specified type.

Parameters
int- ID of object type to find.
Returns
Vertex2 - x, y coordinate of the mouse.

◆ get_camera_id()

int get_camera_id ( )

A game level can use up to 4 cameras, each with its own independent attached script and settings. However, only one camera can be "active" at a time. This method returns the ID of the active camera.

Returns
int ID of the active camera

◆ get_complete()

bool get_complete ( )

Query the engine to determine if the present level has been marked complete.

Returns
bool true if the level has been marked complete, false otherwise

◆ get_id()

int get_id ( )

Query the engine to determine the ID of the present level.

Returns
int the ID associated with the present game level.

◆ get_light_direction()

Vector get_light_direction ( )

Fetch the configured light direction.

Returns
Vector

◆ load()

void load ( string  )

Load the game level Lua script from the file specified.

Parameters
stringname of the game level Lua script to load.
Returns
n/a

◆ load_from_buffer()

void load_from_buffer ( string  )

Load the game level Lua script from the supplied string buffer.

Parameters
stringbuffer containing a game level Lua script to load.
Returns
n/a

◆ pause()

void pause ( )

Pause execution of the game

Returns
n/a

◆ pause_music()

void pause_music ( )

Pause song (if playing). Song will resume where it was paused when played.

Returns
n/a

◆ play_music()

void play_music ( string  ,
int   
)

Playing song specified.

Parameters
stringname of file containing the song to play.
intrepeat control (0 - do not repeat, 1 - repeat).
Returns
n/a

◆ remove_object()

void remove_object ( GameObjectReference  )

Remove the specified object from the level.

Parameters
GameObjectReference
Returns
n/a

◆ set_complete()

void set_complete ( bool  )

The currently running game level maintains a state about whether it has been marked as "complete" or not. This method sets this state.

Parameters
booltrue - level is marked as complete, false - level is not complete
Returns
n/a

◆ set_id()

int set_id ( int  )

Set the ID associated with the present level.

Parameters
level_id
Returns
n/a

◆ set_light_direction() [1/2]

void set_light_direction ( Vector  )

Set the light direction in the game level's scene. This setting affects shading on models and the terrain.

Parameters
Vectorarray containing x, y, z coordinates of the directed light vector
Returns
n/a

◆ set_light_direction() [2/2]

void set_light_direction ( float  ,
float  ,
float   
)

Set the light direction in the game level's scene. This setting affects shading on models and the terrain.

Parameters
floatx coordinate of the directed light vector
floaty coordinate of the directed light vector
floatz coordinate of the directed light vector
Returns
n/a

◆ set_sky_box()

void set_sky_box ( float  ,
float  ,
float  ,
float  ,
float  ,
float  ,
float  ,
float  ,
float   
)

Render a sky box around the level using the three colors supplied. Color 1 is the top color; Color two is in the middle; Color 3 is the bottom color.

Parameters
floatfirst color, red attribute (0.0 - 1.0)
floatfirst color, green attribute (0.0 - 1.0)
floatfirst color, blue attribute (0.0 - 1.0)
floatsecond color, red attribute (0.0 - 1.0)
floatsecond color, green attribute (0.0 - 1.0)
floatsecond color, blue attribute (0.0 - 1.0)
floatthird color, red attribute (0.0 - 1.0)
floatthird color, green attribute (0.0 - 1.0)
floatthird color, blue attribute (0.0 - 1.0)
Returns
n/a

◆ set_terrain()

void set_terrain ( TerrainObjectReference  ,
string   
)

Set the specified level's terrain.

Parameters
TerrainObjectReference
stringterrain file to load.
Returns
n/a

◆ stop_music()

void stop_music ( )

Stop playing song (if playing). Song will restart when played.

Returns
n/a

◆ swap()

void swap ( )

TODO: Undefined

Returns
n/a