本文整理汇总了C++中LuaCheckArgs函数的典型用法代码示例。如果您正苦于以下问题:C++ LuaCheckArgs函数的具体用法?C++ LuaCheckArgs怎么用?C++ LuaCheckArgs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LuaCheckArgs函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CclNewPlayerColors
/**
** Make new player colors
**
** @param l Lua state.
*/
static int CclNewPlayerColors(lua_State *l)
{
LuaCheckArgs(l, 0);
SetPlayersPalette();
return 0;
}
开发者ID:ajaykon,项目名称:Stratagus,代码行数:12,代码来源:script_player.cpp
示例2: CclSavedGameInfo
/**
** Load the SavedGameInfo Header
**
** @param l Lua state.
*/
static int CclSavedGameInfo(lua_State *l)
{
const char *value;
LuaCheckArgs(l, 1);
LuaCheckTable(l, 1);
lua_pushnil(l);
while (lua_next(l, 1)) {
value = LuaToString(l, -2);
if (!strcmp(value, "SaveFile")) {
if (strcpy_s(CurrentMapPath, sizeof(CurrentMapPath), LuaToString(l, -1)) != 0) {
LuaError(l, "SaveFile too long");
}
std::string buf = StratagusLibPath;
buf += "/";
buf += LuaToString(l, -1);
if (LuaLoadFile(buf) == -1) {
DebugPrint("Load failed: %s\n" _C_ value);
}
} else if (!strcmp(value, "SyncHash")) {
SyncHash = LuaToNumber(l, -1);
} else if (!strcmp(value, "SyncRandSeed")) {
SyncRandSeed = LuaToNumber(l, -1);
} else {
LuaError(l, "Unsupported tag: %s" _C_ value);
}
lua_pop(l, 1);
}
return 0;
}
开发者ID:infsega,项目名称:boswars-playbook,代码行数:38,代码来源:script.cpp
示例3: CclKillUnit
/**
** Kill a unit
**
** @param l Lua state.
**
** @return Returns true if a unit was killed.
*/
static int CclKillUnit(lua_State *l)
{
LuaCheckArgs(l, 2);
lua_pushvalue(l, 1);
const CUnitType *unittype = TriggerGetUnitType(l);
lua_pop(l, 1);
const int plynr = TriggerGetPlayer(l);
if (plynr == -1) {
CUnitManager::Iterator it = std::find_if(UnitManager.begin(), UnitManager.end(), HasSameUnitTypeAs(unittype));
if (it != UnitManager.end()) {
LetUnitDie(**it);
lua_pushboolean(l, 1);
return 1;
}
} else {
CPlayer &player = Players[plynr];
std::vector<CUnit *>::iterator it = std::find_if(player.UnitBegin(), player.UnitEnd(), HasSameUnitTypeAs(unittype));
if (it != player.UnitEnd()) {
LetUnitDie(**it);
lua_pushboolean(l, 1);
return 1;
}
}
lua_pushboolean(l, 0);
return 1;
}
开发者ID:wangtianhang,项目名称:stratagus,代码行数:36,代码来源:script_unit.cpp
示例4: CclMakeSound
/**
** Create a sound.
**
** Glue between c and scheme. This function asks the sound system to
** register a sound under a given name, wiht an associated list of files
** (the list can be replaced by only one file).
**
** @param l Lua state.
**
** @return the sound id of the created sound
*/
static int CclMakeSound(lua_State *l)
{
LuaCheckArgs(l, 2);
std::string c_name = LuaToString(l, 1);
std::vector<std::string> files;
CSound *id;
if (lua_isstring(l, 2)) {
// only one file
files.push_back(LuaToString(l, 2));
id = MakeSound(c_name, files);
} else if (lua_istable(l, 2)) {
// several files
const int args = lua_rawlen(l, 2);
files.reserve(args);
for (int j = 0; j < args; ++j) {
lua_rawgeti(l, 2, j + 1);
files.push_back(LuaToString(l, -1));
lua_pop(l, 1);
}
id = MakeSound(c_name, files);
} else {
LuaError(l, "string or table expected");
return 0;
}
LuaUserData *data = (LuaUserData *)lua_newuserdata(l, sizeof(LuaUserData));
data->Type = LuaSoundType;
data->Data = id;
return 1;
}
开发者ID:ajaykon,项目名称:Stratagus,代码行数:41,代码来源:script_sound.cpp
示例5: CclSetEditorStartUnit
/**
** Set the editor's start location unit
**
** @param l Lua state.
*/
static int CclSetEditorStartUnit(lua_State *l)
{
LuaCheckArgs(l, 1);
delete[] Editor.StartUnitName;
Editor.StartUnitName = new_strdup(LuaToString(l, 1));
return 0;
}
开发者ID:k1643,项目名称:StratagusAI,代码行数:12,代码来源:script_editor.cpp
示例6: CclBuildTilesetTables
/**
** Build tileset tables like humanWallTable or mixedLookupTable
**
** Called after DefineTileset and only for tilesets that have wall,
** trees and rocks. This function will be deleted when removing
** support of walls and alike in the tileset.
*/
static int CclBuildTilesetTables(lua_State *l)
{
LuaCheckArgs(l, 0);
Map.Tileset->buildTable(l);
return 0;
}
开发者ID:meiavy,项目名称:Wyrmgus,代码行数:14,代码来源:script_map.cpp
示例7: CclGetVideoResolution
/**
** Get the video resolution.
**
** @param l Lua state.
*/
static int CclGetVideoResolution(lua_State *l)
{
LuaCheckArgs(l, 0);
lua_pushnumber(l, Video.Width);
lua_pushnumber(l, Video.Height);
return 2;
}
开发者ID:realhidden,项目名称:stratagus,代码行数:12,代码来源:script_ui.cpp
示例8: CclShowMapLocation
/**
** Show Map Location
**
** @param l Lua state.
*/
static int CclShowMapLocation(lua_State *l)
{
// Put a unit on map, use its properties, except for
// what is listed below
LuaCheckArgs(l, 4);
const char *unitname = LuaToString(l, 5);
CUnitType *unitType = UnitTypeByIdent(unitname);
if (!unitType) {
DebugPrint("Unable to find UnitType '%s'" _C_ unitname);
return 0;
}
CUnit *target = MakeUnit(*unitType, ThisPlayer);
if (target != NULL) {
target->Variable[HP_INDEX].Value = 0;
target->tilePos.x = LuaToNumber(l, 1);
target->tilePos.y = LuaToNumber(l, 2);
target->TTL = GameCycle + LuaToNumber(l, 4);
target->CurrentSightRange = LuaToNumber(l, 3);
//Wyrmgus start
UpdateUnitSightRange(*target);
//Wyrmgus end
MapMarkUnitSight(*target);
} else {
DebugPrint("Unable to allocate Unit");
}
return 0;
}
开发者ID:meiavy,项目名称:Wyrmgus,代码行数:33,代码来源:script_map.cpp
示例9: CclCheckDependency
/**
** Checks if dependencies are met.
**
** @return true if the dependencies are met.
**
** @param l Lua state.
** Argument 1: player
** Argument 2: object which we want to check the dependencies of
*/
static int CclCheckDependency(lua_State *l)
{
LuaCheckArgs(l, 2);
const char *object = LuaToString(l, 2);
lua_pop(l, 1);
const int plynr = TriggerGetPlayer(l);
if (plynr == -1) {
LuaError(l, "bad player: %i" _C_ plynr);
}
const CPlayer *player = &Players[plynr];
if (!strncmp(object, "unit-", 5)) {
const CUnitType *unit_type = UnitTypeByIdent(object);
if (!unit_type) {
LuaError(l, "Invalid unit type: \"%s\"" _C_ object);
}
lua_pushboolean(l, CheckDependencies(unit_type, player));
} else if (!strncmp(object, "upgrade-", 8)) {
const CUpgrade *upgrade = CUpgrade::Get(object);
if (!upgrade) {
LuaError(l, "Invalid upgrade: \"%s\"" _C_ object);
}
lua_pushboolean(l, CheckDependencies(upgrade, player));
} else {
LuaError(l, "Invalid target of dependency check: \"%s\"" _C_ object);
}
return 1;
}
开发者ID:Andrettin,项目名称:Wyrmgus,代码行数:38,代码来源:dependency.cpp
示例10: CclGroup
/**
** Define the group.
**
** @param l Lua state.
*/
static int CclGroup(lua_State *l)
{
int i;
CUnitGroup *grp;
int args;
int j;
LuaCheckArgs(l, 3);
InitGroups();
grp = &Groups[(int)LuaToNumber(l, 1)];
grp->NumUnits = LuaToNumber(l, 2);
i = 0;
args = lua_objlen(l, 3);
for (j = 0; j < args; ++j) {
const char *str;
lua_rawgeti(l, 3, j + 1);
str = LuaToString(l, -1);
lua_pop(l, 1);
grp->Units[i++] = UnitSlots[strtol(str + 1, NULL, 16)];
}
return 0;
}
开发者ID:landswellsong,项目名称:Stratagus,代码行数:30,代码来源:groups.cpp
示例11: CclDefineMapSetup
/**
** Define the lua file that will build the map
**
** @param l Lua state.
*/
static int CclDefineMapSetup(lua_State *l)
{
LuaCheckArgs(l, 1);
Map.Info.Filename = LuaToString(l, 1);
return 0;
}
开发者ID:realhidden,项目名称:stratagus,代码行数:12,代码来源:script_ui.cpp
示例12: CclGetTileTerrainHasFlag
/**
** Check if the tile's terrain has a particular flag.
**
** @param l Lua state.
**
** @return True if has the flag, false if not.
*/
static int CclGetTileTerrainHasFlag(lua_State *l)
{
LuaCheckArgs(l, 3);
const Vec2i pos(LuaToNumber(l, 1), LuaToNumber(l, 2));
//Wyrmgus start
if (pos.x < 0 || pos.x >= Map.Info.MapWidth || pos.y < 0 || pos.y >= Map.Info.MapHeight) {
lua_pushboolean(l, 0);
return 1;
}
// unsigned short flag = 0;
unsigned long flag = 0;
//Wyrmgus end
const char *flag_name = LuaToString(l, 3);
if (!strcmp(flag_name, "water")) {
flag = MapFieldWaterAllowed;
} else if (!strcmp(flag_name, "land")) {
flag = MapFieldLandAllowed;
} else if (!strcmp(flag_name, "coast")) {
flag = MapFieldCoastAllowed;
} else if (!strcmp(flag_name, "no-building")) {
flag = MapFieldNoBuilding;
} else if (!strcmp(flag_name, "unpassable")) {
flag = MapFieldUnpassable;
//Wyrmgus start
} else if (!strcmp(flag_name, "air-unpassable")) {
flag = MapFieldAirUnpassable;
} else if (!strcmp(flag_name, "dirt")) {
flag = MapFieldDirt;
} else if (!strcmp(flag_name, "grass")) {
flag = MapFieldGrass;
} else if (!strcmp(flag_name, "gravel")) {
flag = MapFieldGravel;
} else if (!strcmp(flag_name, "mud")) {
flag = MapFieldMud;
} else if (!strcmp(flag_name, "stone-floor")) {
flag = MapFieldStoneFloor;
} else if (!strcmp(flag_name, "stumps")) {
flag = MapFieldStumps;
//Wyrmgus end
} else if (!strcmp(flag_name, "wall")) {
flag = MapFieldWall;
} else if (!strcmp(flag_name, "rock")) {
flag = MapFieldRocks;
} else if (!strcmp(flag_name, "forest")) {
flag = MapFieldForest;
}
const CMapField &mf = *Map.Field(pos);
if (mf.getFlag() & flag) {
lua_pushboolean(l, 1);
} else {
lua_pushboolean(l, 0);
}
return 1;
}
开发者ID:meiavy,项目名称:Wyrmgus,代码行数:67,代码来源:script_map.cpp
示例13: CclDefinePlayerColors
/**
** Define player colors
**
** @param l Lua state.
*/
static int CclDefinePlayerColors(lua_State *l)
{
LuaCheckArgs(l, 1);
if (!lua_istable(l, 1)) {
LuaError(l, "incorrect argument");
}
const int args = lua_rawlen(l, 1);
for (int i = 0; i < args; ++i) {
PlayerColorNames[i / 2] = LuaToString(l, 1, i + 1);
++i;
lua_rawgeti(l, 1, i + 1);
if (!lua_istable(l, -1)) {
LuaError(l, "incorrect argument");
}
const int numcolors = lua_rawlen(l, -1);
if (numcolors != PlayerColorIndexCount) {
LuaError(l, "You should use %d colors (See DefinePlayerColorIndex())" _C_ PlayerColorIndexCount);
}
for (int j = 0; j < numcolors; ++j) {
lua_rawgeti(l, -1, j + 1);
PlayerColorsRGB[i / 2][j].Parse(l);
lua_pop(l, 1);
}
}
return 0;
}
开发者ID:bradc6,项目名称:Stratagus,代码行数:33,代码来源:script_player.cpp
示例14: CclSetMetaServer
/**
** Set the metaserver to use for internet play.
**
** @param l Lua state.
*/
int CclSetMetaServer(lua_State *l)
{
LuaCheckArgs(l, 2);
MasterHost = LuaToString(l, 1);
MasterPort = LuaToNumber(l, 2);
return 0;
}
开发者ID:realhidden,项目名称:stratagus,代码行数:13,代码来源:master.cpp
示例15: CclCenterMap
/**
** Center the map.
**
** @param l Lua state.
*/
static int CclCenterMap(lua_State *l)
{
LuaCheckArgs(l, 2);
const Vec2i pos(LuaToNumber(l, 1), LuaToNumber(l, 2));
UI.SelectedViewport->Center(Map.TilePosToMapPixelPos_Center(pos));
return 0;
}
开发者ID:meiavy,项目名称:Wyrmgus,代码行数:13,代码来源:script_map.cpp
示例16: CclSetMaxSelectable
/**
** Set MaxSelectable
**
** @param l Lua state.
*/
static int CclSetMaxSelectable(lua_State *l)
{
LuaCheckArgs(l, 1);
MaxSelectable = LuaToNumber(l, 1);
lua_pushnumber(l, MaxSelectable);
return 1;
}
开发者ID:ajaykon,项目名称:Stratagus,代码行数:13,代码来源:script_player.cpp
示例17: CclCenterMap
/**
** Center the map.
**
** @param l Lua state.
*/
static int CclCenterMap(lua_State *l)
{
LuaCheckArgs(l, 2);
UI.SelectedViewport->Center(
LuaToNumber(l, 1), LuaToNumber(l, 2), TileSizeX / 2, TileSizeY / 2);
return 0;
}
开发者ID:landswellsong,项目名称:Stratagus,代码行数:13,代码来源:script_map.cpp
示例18: CclIfRescuedNearUnit
/**
** Player has the quantity of rescued unit-type near to unit-type.
*/
static int CclIfRescuedNearUnit(lua_State *l)
{
LuaCheckArgs(l, 5);
lua_pushvalue(l, 1);
const int plynr = TriggerGetPlayer(l);
lua_pop(l, 1);
const char *op = LuaToString(l, 2);
const int q = LuaToNumber(l, 3);
lua_pushvalue(l, 4);
const CUnitType *unittype = TriggerGetUnitType(l);
lua_pop(l, 1);
const CUnitType *ut2 = CclGetUnitType(l);
if (!unittype || !ut2) {
LuaError(l, "CclIfRescuedNearUnit: not a unit-type valid");
}
CompareFunction compare = GetCompareFunction(op);
if (!compare) {
LuaError(l, "Illegal comparison operation in if-rescued-near-unit: %s" _C_ op);
}
// Get all unit types 'near'.
std::vector<CUnit *> table;
FindUnitsByType(*ut2, table);
for (size_t i = 0; i != table.size(); ++i) {
CUnit ¢erUnit = *table[i];
std::vector<CUnit *> around;
SelectAroundUnit(centerUnit, 1, around);
// Count the requested units
int s = 0;
for (size_t j = 0; j != around.size(); ++j) {
CUnit &unit = *around[j];
if (unit.RescuedFrom) { // only rescued units
// Check unit type
if (unittype == ANY_UNIT
|| (unittype == ALL_FOODUNITS && !unit.Type->Building)
|| (unittype == ALL_BUILDINGS && unit.Type->Building)
|| (unittype == unit.Type)) {
// Check the player
if (plynr == -1 || plynr == unit.Player->Index) {
++s;
}
}
}
}
if (compare(s, q)) {
lua_pushboolean(l, 1);
return 1;
}
}
lua_pushboolean(l, 0);
return 1;
}
开发者ID:wangtianhang,项目名称:stratagus,代码行数:61,代码来源:trigger.cpp
示例19: CclSetThisPlayer
/**
** Set ThisPlayer.
**
** @param l Lua state.
*/
static int CclSetThisPlayer(lua_State *l)
{
LuaCheckArgs(l, 1);
int plynr = LuaToNumber(l, 1);
ThisPlayer = &Players[plynr];
lua_pushnumber(l, plynr);
return 1;
}
开发者ID:ajaykon,项目名称:Stratagus,代码行数:14,代码来源:script_player.cpp
示例20: CclSetMaxOpenGLTexture
static int CclSetMaxOpenGLTexture(lua_State *l)
{
LuaCheckArgs(l, 1);
#if defined(USE_OPENGL) || defined(USE_GLES)
if (CclInConfigFile) {
GLMaxTextureSizeOverride = LuaToNumber(l, 1);
}
#endif
return 0;
}
开发者ID:realhidden,项目名称:stratagus,代码行数:10,代码来源:script_ui.cpp
注:本文中的LuaCheckArgs函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论