_________ __ __
/ _____// |_____________ _/ |______ ____ __ __ ______
\_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
/ \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \
/_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
\/ \/ \//_____/ \/
______________________ ______________________
T H E W A R B E G I N S
Stratagus - A free fantasy real time strategy game engine
Go to the documentation of this file.
69 extern lua_State *
Lua;
71 extern int LuaLoadFile(
const std::string &file,
const std::string &strArg =
"",
bool exitOnError =
true);
72 extern int LuaCall(
int narg,
int clear,
bool exitOnError =
true);
73 extern int LuaCall(lua_State *L,
int narg,
int nresults,
int base,
bool exitOnError =
true);
75 #define LuaError(l, args) \
78 fprintf(stdout, args); \
79 fprintf(stdout, "\n"); \
80 lua_pushfstring(l, args); lua_error(l); \
83 #define LuaCheckArgs(l, args) \
85 if (lua_gettop(l) != args) { \
86 LuaError(l, "incorrect argument"); \
90 #if LUA_VERSION_NUM <= 501
94 return luaL_getn(l, index);
302 extern const char *
LuaToString(lua_State *l,
int narg);
304 extern float LuaToFloat(lua_State *l,
int narg);
308 extern const char *
LuaToString(lua_State *l,
int index,
int subIndex);
309 extern int LuaToNumber(lua_State *l,
int index,
int subIndex);
311 extern bool LuaToBoolean(lua_State *l,
int index,
int subIndex);
315 extern void LoadCcl(
const std::string &filename,
const std::string &luaArgStr =
"");
317 extern int CclCommand(
const std::string &command,
bool exitOnError =
true);
332 template <
typename T>
333 static void CclGetPos(lua_State *l, T *x , T *y,
const int offset = -1)
335 if (!lua_istable(l, offset) ||
lua_rawlen(l, offset) != 2) {
361 #endif // !__SCRIPT_H__
char C
String.
Definition: script.h:231
UnitDesc * CclParseUnitDesc(lua_State *l)
Parse a number description.
Definition: script.cpp:550
char * Val
index of the lua function.
Definition: script.h:263
NumberDesc * CclParseNumberDesc(lua_State *l)
Definition: script.cpp:660
@ ENumber_Lua
Definition: script.h:101
NumberDesc * Left
Definition: script.h:199
@ ENumber_Min
a / b.
Definition: script.h:107
@ ENumber_GtEq
a > b.
Definition: script.h:112
NumberDesc * Cond
Definition: script.h:234
void LoadCcl(const std::string &filename, const std::string &luaArgStr="")
Initialise Lua.
NumberDesc * Begin
Original string.
Definition: script.h:278
EnumVariable Str2EnumVariable(lua_State *l, const char *s)
Damage calculation for missile.
Definition: script_ui.cpp:456
int LuaToNumber(lua_State *l, int narg)
Definition: script.cpp:363
struct NumberDesc::@21::@27 PlayerData
conditional string.
struct StringDesc::@29::@32 SubString
conditional string.
float LuaToFloat(lua_State *l, int narg)
Definition: script.cpp:378
@ EString_Dir
a lua function.
Definition: script.h:138
size_t lua_rawlen(lua_State *l, int index)
Definition: script.h:92
@ EString_Lua
Definition: script.h:137
@ ENumber_Mul
a - b.
Definition: script.h:105
@ VariableMax
Value of the variable.
Definition: script.h:160
int LuaCall(int narg, int clear, bool exitOnError=true)
Definition: script.cpp:172
@ VariablePercent
(Max - Value)
Definition: script.h:163
NumberDesc * Line
Original string.
Definition: script.h:283
NumberDesc * BTrue
Branch condition.
Definition: script.h:235
lua_State * Lua
Definition: script.cpp:68
EString e
Definition: script.h:260
@ UnitRefGoal
unit->Data.Built.Worker
Definition: script.h:175
@ EString_String
a + b [+ c ...].
Definition: script.h:140
@ UnitRefContainer
unit->Inside.
Definition: script.h:173
int Val
index of the lua function.
Definition: script.h:210
@ VariableValue
Definition: script.h:159
@ ENumber_NumIf
Property of UnitType.
Definition: script.h:124
int LuaLoadFile(const std::string &file, const std::string &strArg="", bool exitOnError=true)
Definition: script.cpp:250
NumberDesc * Damage
True while config file parsing.
Definition: script.cpp:72
Definition: unittype.h:508
struct StringDesc::@29::@30 Concat
Direct value.
@ ENumber_Add
directly a number.
Definition: script.h:103
@ ENumber_UnitStat
strchr(string, char) - s.
Definition: script.h:121
@ VariableIncrease
Max of the variable.
Definition: script.h:161
void SavePreferences()
Load ccl config file.
ENumber e
Definition: script.h:207
int n
Array of operands.
Definition: script.h:266
@ ENumber_Rand
Max(a, b).
Definition: script.h:109
StringDesc * String
Number.
Definition: script.h:269
unsigned int Index
Definition: script.h:209
void * Data
Definition: script.h:61
@ EUnit_Ref
Unit direct reference.
Definition: script.h:131
NumberDesc * Cond
Definition: script.h:272
@ ENumber_Gt
Rand(a) : number in [0..a-1].
Definition: script.h:111
StringDesc * BTrue
Branch condition.
Definition: script.h:273
@ EString_If
Inverse video for the string ("a" -> "~<a~>").
Definition: script.h:142
StringDesc ** Strings
Definition: script.h:265
int CclInConfigFile
Structure to work with lua files.
Definition: script.cpp:70
@ LuaUnitType
Definition: script.h:65
NumberDesc * Number
for Concat two string.
Definition: script.h:268
EUnit
All possible value for a unit.
Definition: script.h:130
StringDesc * DataType
Number of player.
Definition: script.h:240
@ ENumber_Max
Min(a, b).
Definition: script.h:108
struct NumberDesc::@21::@25 StringFind
@ LuaSoundType
Definition: script.h:66
struct StringDesc::@29::@31 If
Unit desciption.
CUnit * EvalUnit(const UnitDesc *unitdesc)
Evaluate the number.
Definition: script.cpp:965
NumberDesc * MaxLen
Line number.
Definition: script.h:284
NumberDesc * Player
Definition: script.h:239
@ ENumber_PlayerData
If cond then Number1 else Number2.
Definition: script.h:126
for Bin operand a ?? b
Definition: script.h:198
@ EString_SubString
UnitType Name.
Definition: script.h:144
@ ENumber_Lt
a >= b.
Definition: script.h:113
StringDesc * CclParseStringDesc(lua_State *l)
Parse a unit type description.
Definition: script.cpp:851
NumberDesc * N
Direct value.
Definition: script.h:211
@ ENumber_LtEq
a < b.
Definition: script.h:114
@ VariableDiff
Increase value of the variable.
Definition: script.h:162
@ UnitRefInside
unit.
Definition: script.h:172
int Type
Definition: script.h:60
@ ENumber_TypeStat
Property of Unit.
Definition: script.h:122
StringDesc * BFalse
String if Cond is true.
Definition: script.h:274
ES_GameInfo
All possible value for a game info string.
Definition: script.h:151
CUnit * CclGetUnitFromRef(lua_State *l)
For saving lua state.
Definition: script_unit.cpp:178
ES_GameInfo GameInfoType
For specific line.
Definition: script.h:287
@ ES_GameInfo_Objectives
All Objectives of the game.
Definition: script.h:152
bool LuaToBoolean(lua_State *l, int narg)
Definition: script.cpp:408
static void CclGetPos(lua_State *l, T *x, T *y, const int offset=-1)
Definition: script.h:333
@ EString_InverseVideo
Convert number in string.
Definition: script.h:141
void FreeNumberDesc(NumberDesc *number)
Evaluate the string.
Definition: script.cpp:1224
int CclCommand(const std::string &command, bool exitOnError=true)
Save user preferences.
Definition: script.cpp:2191
@ ENumber_Dir
a lua function.
Definition: script.h:102
@ ENumber_StringFind
VideoTextLength(font, string).
Definition: script.h:119
@ ENumber_Sub
a + b.
Definition: script.h:104
struct NumberDesc::@21::@23 TypeStat
UnitDesc * Unit
Definition: script.h:214
EnumUnit
Definition: script.h:170
int Index
Which unit.
Definition: script.h:215
@ VariableName
(100 * Value / Max)
Definition: script.h:164
NumberDesc * Right
Left operand.
Definition: script.h:200
UnitDesc * Unit
String.
Definition: script.h:270
union StringDesc::@29 D
which number.
ENumber
All possible value for a number.
Definition: script.h:100
union NumberDesc::@21 D
which number.
@ ENumber_Eq
a <= b.
Definition: script.h:115
@ EString_Concat
directly a string.
Definition: script.h:139
#define LuaError(l, args)
Definition: script.h:75
void LuaGarbageCollect()
Definition: script.cpp:454
int Loc
Which component.
Definition: script.h:217
@ ENumber_Div
a * b.
Definition: script.h:106
void FreeUnitDesc(UnitDesc *unitdesc)
Free number description content. (no pointer itself).
Definition: script.cpp:1210
@ ENumber_VideoTextLength
a <> b.
Definition: script.h:118
CFont * Font
Max length of line.
Definition: script.h:285
StringDesc * ResType
Player's data.
Definition: script.h:241
unsigned int Index
Definition: script.h:262
std::string SaveGlobal(lua_State *l)
struct NumberDesc::@21::@22 UnitStat
For binary operand.
@ EString_PlayerName
line n of the string.
Definition: script.h:146
NumberDesc * BFalse
Number if Cond is true.
Definition: script.h:236
CFont * Font
String.
Definition: script.h:227
BinOp binOp
Other number.
Definition: script.h:212
NumberDesc * PlayerName
Definition: script.h:288
void InitLua()
Perform garbage collection.
Definition: script.cpp:2212
@ EString_Line
SubString.
Definition: script.h:145
CUnitType ** Type
Definition: script.h:220
struct NumberDesc::@21::@24 VideoTextLength
struct NumberDesc::@21::@26 NumIf
CUnit ** AUnit
Definition: script.h:252
int EvalNumber(const NumberDesc *numberdesc)
Parse a string description.
Definition: script.cpp:990
@ EString_UnitName
If cond then String1 else String2.
Definition: script.h:143
const char * LuaToString(lua_State *l, int narg)
True while config file parsing.
Definition: script.cpp:348
StringDesc * String
Definition: script.h:226
union UnitDesc::@28 D
which unit;
void FreeStringDesc(StringDesc *s)
Free unit description content. (no pointer itself).
Definition: script.cpp:1294
@ UnitRefWorker
Unit->Container.
Definition: script.h:174
unsigned int LuaToUnsignedNumber(lua_State *l, int narg)
Definition: script.cpp:393
@ ENumber_NEq
a == b.
Definition: script.h:116
EUnit e
Definition: script.h:250
EnumVariable
Definition: script.h:158
CUnitType ** CclParseTypeDesc(lua_State *l)
Parse a unit description.
Definition: script.cpp:572
@ UnitRefItSelf
Definition: script.h:171
EString
All possible value for a string.
Definition: script.h:136
std::string EvalString(const StringDesc *s)
Evaluate the unit.
Definition: script.cpp:1110
The big unit structure.
Definition: unit.h:135
NumberDesc * End
Begin of result string.
Definition: script.h:279
Font definition.
Definition: font.h:73
EnumVariable Component
Which index variable.
Definition: script.h:216
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.