Lua Variables.
More...
#include <inttypes.h>
#include "lvar.h"
#include "array.h"
#include "nlua_time.h"
#include "nluadef.h"
Go to the source code of this file.
|
| static int | lvar_cmp (const void *p1, const void *p2) |
| | Compares two lua variable names. For use with qsort/bsearch.
|
| static void | lvar_free (lvar *var) |
| | Frees a lua variable.
|
| lvar * | lvar_get (const lvar *arr, const char *str) |
| | Gets a lua var by name.
|
| int | lvar_push (lua_State *L, const lvar *v) |
| | Pushes a lua var to a lua state.
|
| lvar | lvar_tovar (lua_State *L, const char *name, int idx) |
| | Gets a lua variable from an index from a lua state.
|
| void | lvar_freeArray (lvar *arr) |
| | Frees a variable array.
|
| int | lvar_addArray (lvar **arr, const lvar *new_var, int sort) |
| | Adds a var to a var array.
|
| void | lvar_rmArray (lvar **arr, lvar *rm_var) |
| | Removes a var from a var array.
|
| int | lvar_save (const lvar *arr, xmlTextWriterPtr writer) |
| | Saves the mission variables.
|
| lvar * | lvar_load (xmlNodePtr parent) |
| | Loads the vars from XML file.
|
Lua Variables.
Definition in file lvar.c.
◆ lvar_addArray()
| int lvar_addArray |
( |
lvar ** | arr, |
|
|
const lvar * | new_var, |
|
|
int | sort ) |
Adds a var to a var array.
- Parameters
-
| arr | Array to add var to (should be already initialized). |
| new_var | New variable to add to array. |
| sort | Whether or not to sort. |
- Returns
- 0 on success.
Definition at line 160 of file lvar.c.
◆ lvar_cmp()
| int lvar_cmp |
( |
const void * | p1, |
|
|
const void * | p2 ) |
|
static |
Compares two lua variable names. For use with qsort/bsearch.
Definition at line 26 of file lvar.c.
◆ lvar_free()
| void lvar_free |
( |
lvar * | var | ) |
|
|
static |
Frees a lua variable.
- Parameters
-
Definition at line 123 of file lvar.c.
◆ lvar_freeArray()
| void lvar_freeArray |
( |
lvar * | arr | ) |
|
Frees a variable array.
- Parameters
-
Definition at line 145 of file lvar.c.
◆ lvar_get()
| lvar * lvar_get |
( |
const lvar * | arr, |
|
|
const char * | str ) |
Gets a lua var by name.
- Parameters
-
| arr | Array to search in. |
| str | Name to use as a key. |
- Returns
- Found element or NULL if not found.
Definition at line 41 of file lvar.c.
◆ lvar_load()
| lvar * lvar_load |
( |
xmlNodePtr | parent | ) |
|
Loads the vars from XML file.
- Parameters
-
| parent | Parent node containing the variables. |
- Returns
- Newly allocated lua variable array or NULL on error.
Definition at line 241 of file lvar.c.
◆ lvar_push()
| int lvar_push |
( |
lua_State * | L, |
|
|
const lvar * | v ) |
Pushes a lua var to a lua state.
- Parameters
-
| L | Lua state to push to. |
| v | Lua variable to push. |
- Returns
- Number of elements pushed onto the stack.
Definition at line 56 of file lvar.c.
◆ lvar_rmArray()
| void lvar_rmArray |
( |
lvar ** | arr, |
|
|
lvar * | rm_var ) |
Removes a var from a var array.
- Parameters
-
| arr | Array to remove var from. |
| rm_var | Var to remove. |
Definition at line 187 of file lvar.c.
◆ lvar_save()
| int lvar_save |
( |
const lvar * | arr, |
|
|
xmlTextWriterPtr | writer ) |
Saves the mission variables.
- Parameters
-
| arr | Array to save. |
| writer | XML Writer to use. |
- Returns
- 0 on success.
Definition at line 200 of file lvar.c.
◆ lvar_tovar()
| lvar lvar_tovar |
( |
lua_State * | L, |
|
|
const char * | name, |
|
|
int | idx ) |
Gets a lua variable from an index from a lua state.
- Parameters
-
| L | Lua state to get var from. |
| name | Name of the variable. |
| idx | Index to get value from. |
- Returns
- New lua variable that should be freed with lvar_free().
Definition at line 86 of file lvar.c.