_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
#include <string>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
Go to the source code of this file.
Classes | |
struct | LuaUserData |
struct | BinOp |
for Bin operand a ?? b More... | |
struct | NumberDesc |
struct | UnitDesc |
struct | StringDesc |
script.h - The clone configuration language headerfile. | |
#define | LuaError(l, args) |
#define | LuaCheckArgs(l, args) |
enum | { LuaUnitType = 100, LuaSoundType } |
enum | ENumber { ENumber_Lua, ENumber_Dir, ENumber_Add, ENumber_Sub, ENumber_Mul, ENumber_Div, ENumber_Min, ENumber_Max, ENumber_Rand, ENumber_Gt, ENumber_GtEq, ENumber_Lt, ENumber_LtEq, ENumber_Eq, ENumber_NEq, ENumber_VideoTextLength, ENumber_StringFind, ENumber_UnitStat, ENumber_TypeStat, ENumber_NumIf, ENumber_PlayerData } |
All possible value for a number. More... | |
enum | EUnit { EUnit_Ref } |
All possible value for a unit. More... | |
enum | EString { EString_Lua, EString_Dir, EString_Concat, EString_String, EString_InverseVideo, EString_If, EString_UnitName, EString_SubString, EString_Line, EString_PlayerName } |
All possible value for a string. More... | |
enum | ES_GameInfo { ES_GameInfo_Objectives } |
All possible value for a game info string. More... | |
enum | EnumVariable { VariableValue = 0, VariableMax, VariableIncrease, VariableDiff, VariablePercent, VariableName } |
enum | EnumUnit { UnitRefItSelf = 0, UnitRefInside, UnitRefContainer, UnitRefWorker, UnitRefGoal } |
lua_State * | Lua |
int | CclInConfigFile |
Structure to work with lua files. More... | |
NumberDesc * | Damage |
True while config file parsing. More... | |
int | LuaLoadFile (const std::string &file, const std::string &strArg="", bool exitOnError=true) |
int | LuaCall (int narg, int clear, bool exitOnError=true) |
int | LuaCall (lua_State *L, int narg, int nresults, int base, bool exitOnError=true) |
size_t | lua_rawlen (lua_State *l, int index) |
const char * | LuaToString (lua_State *l, int narg) |
True while config file parsing. More... | |
int | LuaToNumber (lua_State *l, int narg) |
float | LuaToFloat (lua_State *l, int narg) |
unsigned int | LuaToUnsignedNumber (lua_State *l, int narg) |
bool | LuaToBoolean (lua_State *l, int narg) |
const char * | LuaToString (lua_State *l, int index, int subIndex) |
int | LuaToNumber (lua_State *l, int index, int subIndex) |
unsigned int | LuaToUnsignedNumber (lua_State *l, int index, int subIndex) |
bool | LuaToBoolean (lua_State *l, int index, int subIndex) |
void | LuaGarbageCollect () |
void | InitLua () |
Perform garbage collection. More... | |
void | LoadCcl (const std::string &filename, const std::string &luaArgStr="") |
Initialise Lua. More... | |
void | SavePreferences () |
Load ccl config file. More... | |
int | CclCommand (const std::string &command, bool exitOnError=true) |
Save user preferences. More... | |
void | ScriptRegister () |
std::string | SaveGlobal (lua_State *l) |
CUnit * | CclGetUnitFromRef (lua_State *l) |
For saving lua state. More... | |
template<typename T > | |
static void | CclGetPos (lua_State *l, T *x, T *y, const int offset=-1) |
EnumVariable | Str2EnumVariable (lua_State *l, const char *s) |
Damage calculation for missile. More... | |
NumberDesc * | CclParseNumberDesc (lua_State *l) |
UnitDesc * | CclParseUnitDesc (lua_State *l) |
Parse a number description. More... | |
CUnitType ** | CclParseTypeDesc (lua_State *l) |
Parse a unit description. More... | |
StringDesc * | CclParseStringDesc (lua_State *l) |
Parse a unit type description. More... | |
int | EvalNumber (const NumberDesc *numberdesc) |
Parse a string description. More... | |
CUnit * | EvalUnit (const UnitDesc *unitdesc) |
Evaluate the number. More... | |
std::string | EvalString (const StringDesc *s) |
Evaluate the unit. More... | |
void | FreeNumberDesc (NumberDesc *number) |
Evaluate the string. More... | |
void | FreeUnitDesc (UnitDesc *unitdesc) |
Free number description content. (no pointer itself). More... | |
void | FreeStringDesc (StringDesc *s) |
Free unit description content. (no pointer itself). More... | |
#define LuaCheckArgs | ( | l, | |
args | |||
) |
#define LuaError | ( | l, | |
args | |||
) |
enum ENumber |
All possible value for a number.
enum EnumUnit |
enum EnumVariable |
enum ES_GameInfo |
enum EString |
All possible value for a string.
enum EUnit |
int CclCommand | ( | const std::string & | command, |
bool | exitOnError | ||
) |
Save user preferences.
Send command to ccl.
command | Zero terminated command string. |
|
static |
Get a position from lua state
l | Lua state. |
x | pointer to output x position. |
y | pointer to output y position. |
CUnit* CclGetUnitFromRef | ( | lua_State * | l | ) |
For saving lua state.
Get a unit pointer from ref string
l | Lua state. |
NumberDesc* CclParseNumberDesc | ( | lua_State * | l | ) |
Return number.
l | lua state. |
StringDesc* CclParseStringDesc | ( | lua_State * | l | ) |
Parse a unit type description.
Return String description.
l | lua state. |
CUnitType** CclParseTypeDesc | ( | lua_State * | l | ) |
Parse a unit description.
Return unit type referernce definition.
l | lua state. |
UnitDesc* CclParseUnitDesc | ( | lua_State * | l | ) |
Parse a number description.
Return unit referernce definition.
l | lua state. |
int EvalNumber | ( | const NumberDesc * | number | ) |
Parse a string description.
compute the number expression
number | struct with definition of the calculation. |
std::string EvalString | ( | const StringDesc * | s | ) |
Evaluate the unit.
compute the string expression
s | struct with definition of the calculation. |
Evaluate the number.
compute the Unit expression
unitdesc | struct with definition of the calculation. |
void FreeNumberDesc | ( | NumberDesc * | number | ) |
Evaluate the string.
Free the number expression content. (not the pointer itself).
number | struct to free |
void FreeStringDesc | ( | StringDesc * | s | ) |
Free unit description content. (no pointer itself).
Free the String expression content. (not the pointer itself).
s | struct to free |
Free number description content. (no pointer itself).
Free the unit expression content. (not the pointer itself).
unitdesc | struct to free |
void InitLua | ( | ) |
Perform garbage collection.
Initialize Lua
void LoadCcl | ( | const std::string & | filename, |
const std::string & | luaArgStr = "" |
||
) |
Initialise Lua.
|
inline |
int LuaCall | ( | int | narg, |
int | clear, | ||
bool | exitOnError | ||
) |
Call a lua function
narg | Number of arguments |
clear | Clear the return value(s) |
exitOnError | Exit the program when an error occurs |
int LuaCall | ( | lua_State * | L, |
int | narg, | ||
int | nresults, | ||
int | base, | ||
bool | exitOnError | ||
) |
Call a lua function
L | Pointer to Lua state |
narg | Number of arguments |
nresults | Number of return values |
base | Stack index of the function to call |
exitOnError | Exit the program when an error occurs |
void LuaGarbageCollect | ( | ) |
Perform lua garbage collection
int LuaLoadFile | ( | const std::string & | file, |
const std::string & | strArg, | ||
bool | exitOnError | ||
) |
Load a file and execute it
file | File to load and execute |
nargs | Number of arguments that caller has put on the stack |
bool LuaToBoolean | ( | lua_State * | l, |
int | index, | ||
int | subIndex | ||
) |
bool LuaToBoolean | ( | lua_State * | l, |
int | narg | ||
) |
Convert lua boolean to bool. It also checks type and exits in case of error.
l | Lua state. |
narg | Argument number. |
float LuaToFloat | ( | lua_State * | l, |
int | narg | ||
) |
Convert lua number in C float. It checks also type and exit in case of error.
l | Lua state. |
narg | Argument number. |
int LuaToNumber | ( | lua_State * | l, |
int | index, | ||
int | subIndex | ||
) |
int LuaToNumber | ( | lua_State * | l, |
int | narg | ||
) |
Convert lua number in C number. It checks also type and exit in case of error.
l | Lua state. |
narg | Argument number. |
const char* LuaToString | ( | lua_State * | l, |
int | index, | ||
int | subIndex | ||
) |
const char* LuaToString | ( | lua_State * | l, |
int | narg | ||
) |
True while config file parsing.
Convert lua string in char*. It checks also type and exit in case of error.
l | Lua state. |
narg | Argument number. |
unsigned int LuaToUnsignedNumber | ( | lua_State * | l, |
int | index, | ||
int | subIndex | ||
) |
unsigned int LuaToUnsignedNumber | ( | lua_State * | l, |
int | narg | ||
) |
Convert lua number in C unsigned int. It checks also type and exit in case of error.
l | Lua state. |
narg | Argument number. |
std::string SaveGlobal | ( | lua_State * | l | ) |
void SavePreferences | ( | ) |
Load ccl config file.
void ScriptRegister | ( | ) |
EnumVariable Str2EnumVariable | ( | lua_State * | l, |
const char * | s | ||
) |
Damage calculation for missile.
transform string in corresponding index.
Return enum from string about variable component.
l | Lua State. |
s | string to convert. |
int CclInConfigFile |
Structure to work with lua files.
NumberDesc* Damage |
True while config file parsing.
lua_State* Lua |