本文整理汇总了C++中pushBoolean函数的典型用法代码示例。如果您正苦于以下问题:C++ pushBoolean函数的具体用法?C++ pushBoolean怎么用?C++ pushBoolean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pushBoolean函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pushBoolean
int LuaBinder::luaResultNext(lua_State* L)
{
DBResult_ptr res = LuaBinder::getDBResult(L);
if (!res) {
pushBoolean(L, false);
return 1;
}
pushBoolean(L, res->next());
return 1;
}
开发者ID:slavidodo,项目名称:coppem-server,代码行数:11,代码来源:luaenv.cpp
示例2: getScriptEnv
int NpcScriptInterface::luaActionFollow(lua_State* L)
{
//selfFollow(player)
Npc* npc = getScriptEnv()->getNpc();
if (!npc) {
pushBoolean(L, false);
return 1;
}
pushBoolean(L, npc->setFollowCreature(getPlayer(L, 1)));
return 1;
}
开发者ID:marksamman,项目名称:forgottenserver,代码行数:12,代码来源:npc.cpp
示例3: pushInt
int CCLuaEngine::pushCCLuaValue(const CCLuaValue& value)
{
const CCLuaValueType type = value.getType();
if (type == CCLuaValueTypeInt)
{
return pushInt(value.intValue());
}
else if (type == CCLuaValueTypeFloat)
{
return pushFloat(value.floatValue());
}
else if (type == CCLuaValueTypeBoolean)
{
return pushBoolean(value.booleanValue());
}
else if (type == CCLuaValueTypeString)
{
return pushString(value.stringValue().c_str());
}
else if (type == CCLuaValueTypeDict)
{
pushCCLuaValueDict(value.dictValue());
}
else if (type == CCLuaValueTypeArray)
{
pushCCLuaValueArray(value.arrayValue());
}
else if (type == CCLuaValueTypeCCObject)
{
pushCCObject(value.ccobjectValue(), value.getCCObjectTypename().c_str());
}
return lua_gettop(m_state);
}
开发者ID:JoeHu,项目名称:ccgui,代码行数:34,代码来源:CCLuaEngine.cpp
示例4: switch
void Stack::pushVariable(const Variable &var) {
switch (var.getType()) {
case kTypeNil:
pushNil();
break;
case kTypeBoolean:
pushBoolean(var.getBool());
break;
case kTypeNumber:
pushFloat(var.getFloat());
break;
case kTypeString:
pushString(var.getString());
break;
case kTypeTable:
pushTable(var.getTable());
break;
case kTypeFunction:
pushFunction(var.getFunction());
break;
case kTypeUserType:
pushRawUserType(var.getRawUserType(), var.getExactType());
break;
default:
warning("Pushing a varible of type \"%s\" not supported",
var.getExactType().c_str());
break;
}
}
开发者ID:ImperatorPrime,项目名称:xoreos,代码行数:29,代码来源:stack.cpp
示例5: unregisterMovementEventHandler
void DBCCArmatureNode::registerMovementEventHandler(cocos2d::LUA_FUNCTION func)
{
unregisterMovementEventHandler();
_movementEventHandler = func;
auto dispatcher = getCCEventDispatcher();
auto f = [this](cocos2d::EventCustom *event)
{
auto eventData = (dragonBones::EventData*)(event->getUserData());
auto type = (int) eventData->getType();
auto movementId = eventData->animationState->name;
auto lastState = eventData->armature->getAnimation()->getLastAnimationState();
auto stack = cocos2d::LuaEngine::getInstance()->getLuaStack();
stack->pushObject(this, "db.DBCCArmatureNode");
stack->pushInt(type);
stack->pushString(movementId.c_str(), movementId.size());
stack->pushBoolean(lastState == eventData->animationState);
stack->executeFunctionByHandler(_movementEventHandler, 4);
};
dispatcher->addCustomEventListener(dragonBones::EventData::COMPLETE, f);
dispatcher->addCustomEventListener(dragonBones::EventData::LOOP_COMPLETE, f);
}
开发者ID:602147629,项目名称:Tui-x,代码行数:26,代码来源:DBCCArmatureNode.cpp
示例6: pushInt
void LuaStack::pushLuaValue(const LuaValue& value)
{
const LuaValueType type = value.getType();
if (type == LuaValueTypeInt)
{
return pushInt(value.intValue());
}
else if (type == LuaValueTypeFloat)
{
return pushFloat(value.floatValue());
}
else if (type == LuaValueTypeBoolean)
{
return pushBoolean(value.booleanValue());
}
else if (type == LuaValueTypeString)
{
return pushString(value.stringValue().c_str());
}
else if (type == LuaValueTypeDict)
{
pushLuaValueDict(value.dictValue());
}
else if (type == LuaValueTypeArray)
{
pushLuaValueArray(value.arrayValue());
}
else if (type == LuaValueTypeObject)
{
pushObject(value.ccobjectValue(), value.getObjectTypename().c_str());
}
}
开发者ID:Ben-Cortina,项目名称:GameBox,代码行数:32,代码来源:CCLuaStack.cpp
示例7: getScriptEnv
int32_t NpcScriptInterface::luaCloseShopWindow(lua_State* L)
{
//closeShopWindow(cid)
ScriptEnvironment* env = getScriptEnv();
Player* player = g_game.getPlayerByID(popNumber(L));
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
pushBoolean(L, false);
return 1;
}
Npc* npc = env->getNpc();
if (!npc) {
reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
pushBoolean(L, false);
return 1;
}
int32_t buyCallback;
int32_t sellCallback;
Npc* merchant = player->getShopOwner(buyCallback, sellCallback);
//Check if we actually have a shop window with this player.
if (merchant == npc) {
player->sendCloseShop();
if (buyCallback != -1) {
luaL_unref(L, LUA_REGISTRYINDEX, buyCallback);
}
if (sellCallback != -1) {
luaL_unref(L, LUA_REGISTRYINDEX, sellCallback);
}
player->setShopOwner(NULL, -1, -1);
npc->removeShopPlayer(player);
}
pushBoolean(L, true);
return 1;
}
开发者ID:fabianobn,项目名称:forgottenserver,代码行数:45,代码来源:npc.cpp
示例8: getScriptEnv
int32_t NpcScriptInterface::luaGetNpcName(lua_State* L)
{
//getNpcName()
Npc* npc = getScriptEnv()->getNpc();
if (npc) {
LuaScriptInterface::pushString(L, npc->getName());
} else {
pushBoolean(L, false);
}
return 1;
}
开发者ID:Jonas21,项目名称:forgottenserver,代码行数:11,代码来源:npc.cpp
示例9: pushBoolean
int32_t NpcScriptInterface::luaActionFollow(lua_State* L)
{
//selfFollow(cid)
uint32_t cid = popNumber<uint32_t>(L);
Player* player = g_game.getPlayerByID(cid);
if (cid != 0 && !player) {
pushBoolean(L, false);
return 1;
}
Npc* npc = getScriptEnv()->getNpc();
if (!npc) {
pushBoolean(L, false);
return 1;
}
pushBoolean(L, npc->setFollowCreature(player));
return 1;
}
开发者ID:EnzzoCaaue,项目名称:forgottenserver,代码行数:20,代码来源:npc.cpp
示例10: handle_lua_onConnection
void NBGNetManager::handle_lua_onConnection(bool success)
{
if (luaHandler_onConnection > 0)
{
auto engine = LuaEngine::getInstance();
auto stack = engine->getLuaStack();
stack->pushBoolean(success);
stack->executeFunctionByHandler(luaHandler_onConnection, 1);
stack->clean();
}
}
开发者ID:ourgames,项目名称:nbg,代码行数:11,代码来源:NBGNetManager.cpp
示例11: getCreature
int NpcScriptInterface::luaNpcSetFocus(lua_State* L)
{
// npc:setFocus(creature)
Creature* creature = getCreature(L, 2);
Npc* npc = getUserdata<Npc>(L, 1);
if (npc) {
npc->setCreatureFocus(creature);
pushBoolean(L, true);
} else {
lua_pushnil(L);
}
return 1;
}
开发者ID:marksamman,项目名称:forgottenserver,代码行数:13,代码来源:npc.cpp
示例12: getPlayer
int NpcScriptInterface::luaNpcCloseShopWindow(lua_State* L)
{
// npc:closeShopWindow(player)
Player* player = getPlayer(L, 2);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
pushBoolean(L, false);
return 1;
}
Npc* npc = getUserdata<Npc>(L, 1);
if (!npc) {
reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
pushBoolean(L, false);
return 1;
}
int32_t buyCallback;
int32_t sellCallback;
Npc* merchant = player->getShopOwner(buyCallback, sellCallback);
if (merchant == npc) {
player->sendCloseShop();
if (buyCallback != -1) {
luaL_unref(L, LUA_REGISTRYINDEX, buyCallback);
}
if (sellCallback != -1) {
luaL_unref(L, LUA_REGISTRYINDEX, sellCallback);
}
player->setShopOwner(nullptr, -1, -1);
npc->removeShopPlayer(player);
}
pushBoolean(L, true);
return 1;
}
开发者ID:marksamman,项目名称:forgottenserver,代码行数:38,代码来源:npc.cpp
示例13: popNumber
int32_t NpcScriptInterface::luaActionFollow(lua_State* L)
{
//selfFollow(cid)
uint32_t cid = popNumber(L);
ScriptEnvironment* env = getScriptEnv();
Player* player = g_game.getPlayerByID(cid);
if (cid != 0 && !player) {
pushBoolean(L, false);
return 1;
}
Npc* npc = env->getNpc();
if (!npc) {
pushBoolean(L, false);
return 1;
}
bool result = npc->setFollowCreature(player, true);
pushBoolean(L, result);
return 1;
}
开发者ID:fabianobn,项目名称:forgottenserver,代码行数:24,代码来源:npc.cpp
示例14: lua_pop
int NpcScriptInterface::luaOpenShopWindow(lua_State* L)
{
//openShopWindow(cid, items, onBuy callback, onSell callback)
int32_t sellCallback;
if (lua_isfunction(L, -1) == 0) {
sellCallback = -1;
lua_pop(L, 1); // skip it - use default value
} else {
sellCallback = popCallback(L);
}
int32_t buyCallback;
if (lua_isfunction(L, -1) == 0) {
buyCallback = -1;
lua_pop(L, 1); // skip it - use default value
} else {
buyCallback = popCallback(L);
}
if (lua_istable(L, -1) == 0) {
reportError(__FUNCTION__, "item list is not a table.");
pushBoolean(L, false);
return 1;
}
std::list<ShopInfo> items;
lua_pushnil(L);
while (lua_next(L, -2) != 0) {
const auto tableIndex = lua_gettop(L);
ShopInfo item;
item.itemId = getField<uint32_t>(L, tableIndex, "id");
item.subType = getField<int32_t>(L, tableIndex, "subType");
if (item.subType == 0) {
item.subType = getField<int32_t>(L, tableIndex, "subtype");
lua_pop(L, 1);
}
item.buyPrice = getField<uint32_t>(L, tableIndex, "buy");
item.sellPrice = getField<uint32_t>(L, tableIndex, "sell");
item.realName = getFieldString(L, tableIndex, "name");
items.push_back(item);
lua_pop(L, 6);
}
lua_pop(L, 1);
Player* player = getPlayer(L, -1);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
pushBoolean(L, false);
return 1;
}
//Close any eventual other shop window currently open.
player->closeShopWindow(false);
Npc* npc = getScriptEnv()->getNpc();
if (!npc) {
reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
pushBoolean(L, false);
return 1;
}
npc->addShopPlayer(player);
player->setShopOwner(npc, buyCallback, sellCallback);
player->openShopWindow(npc, items);
pushBoolean(L, true);
return 1;
}
开发者ID:marksamman,项目名称:forgottenserver,代码行数:71,代码来源:npc.cpp
示例15: lua_gettop
int32_t NpcScriptInterface::luaDoSellItem(lua_State* L)
{
//doSellItem(cid, itemid, amount, <optional> subtype, <optional> actionid, <optional: default: 1> canDropOnMap)
int32_t parameters = lua_gettop(L);
bool canDropOnMap;
if (parameters > 5) {
canDropOnMap = popBoolean(L);
} else {
canDropOnMap = true;
}
uint32_t actionId = 0;
if (parameters > 4) {
actionId = popNumber(L);
}
uint32_t subType = 1;
if (parameters > 3) {
int32_t n = popNumber(L);
if (n != -1) {
subType = n;
}
}
uint32_t amount = popNumber(L);
uint32_t itemId = popNumber(L);
Player* player = g_game.getPlayerByID(popNumber(L));
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
pushBoolean(L, false);
return 1;
}
uint32_t sellCount = 0;
const ItemType& it = Item::items[itemId];
if (it.stackable) {
while (amount > 0) {
int32_t stackCount = std::min<int32_t>(100, amount);
Item* item = Item::CreateItem(it.id, stackCount);
if (item && actionId != 0) {
item->setActionId(actionId);
}
if (g_game.internalPlayerAddItem(player, item, canDropOnMap) != RET_NOERROR) {
delete item;
lua_pushnumber(L, sellCount);
return 1;
}
amount = amount - stackCount;
sellCount += stackCount;
}
} else {
for (uint32_t i = 0; i < amount; ++i) {
Item* item = Item::CreateItem(it.id, subType);
if (item && actionId != 0) {
item->setActionId(actionId);
}
if (g_game.internalPlayerAddItem(player, item, canDropOnMap) != RET_NOERROR) {
delete item;
lua_pushnumber(L, sellCount);
return 1;
}
++sellCount;
}
}
lua_pushnumber(L, sellCount);
return 1;
}
开发者ID:Jonas21,项目名称:forgottenserver,代码行数:75,代码来源:npc.cpp
示例16: reportErrorFunc
int NpcScriptInterface::luaNpcOpenShopWindow(lua_State* L)
{
// npc:openShopWindow(cid, items, buyCallback, sellCallback)
if (!isTable(L, 3)) {
reportErrorFunc("item list is not a table.");
pushBoolean(L, false);
return 1;
}
Player* player = getPlayer(L, 2);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
pushBoolean(L, false);
return 1;
}
Npc* npc = getUserdata<Npc>(L, 1);
if (!npc) {
reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
pushBoolean(L, false);
return 1;
}
int32_t sellCallback = -1;
if (LuaScriptInterface::isFunction(L, 5)) {
sellCallback = luaL_ref(L, LUA_REGISTRYINDEX);
}
int32_t buyCallback = -1;
if (LuaScriptInterface::isFunction(L, 4)) {
buyCallback = luaL_ref(L, LUA_REGISTRYINDEX);
}
std::list<ShopInfo> items;
lua_pushnil(L);
while (lua_next(L, 3) != 0) {
const auto tableIndex = lua_gettop(L);
ShopInfo item;
item.itemId = getField<uint32_t>(L, tableIndex, "id");
item.subType = getField<int32_t>(L, tableIndex, "subType");
if (item.subType == 0) {
item.subType = getField<int32_t>(L, tableIndex, "subtype");
lua_pop(L, 1);
}
item.buyPrice = getField<uint32_t>(L, tableIndex, "buy");
item.sellPrice = getField<uint32_t>(L, tableIndex, "sell");
item.realName = getFieldString(L, tableIndex, "name");
items.push_back(item);
lua_pop(L, 6);
}
lua_pop(L, 1);
player->closeShopWindow(false);
npc->addShopPlayer(player);
player->setShopOwner(npc, buyCallback, sellCallback);
player->openShopWindow(npc, items);
pushBoolean(L, true);
return 1;
}
开发者ID:marksamman,项目名称:forgottenserver,代码行数:65,代码来源:npc.cpp
示例17: safeCall
int LuaInterface::signalCall(int numArgs, int numRets)
{
int rets = 0;
int funcIndex = -numArgs-1;
try {
// must be a function
if(isFunction(funcIndex)) {
rets = safeCall(numArgs);
if(numRets != -1) {
if(rets != numRets)
throw LuaException("function call didn't return the expected number of results", 0);
}
}
// can also calls table of functions
else if(isTable(funcIndex)) {
// loop through table values
pushNil();
bool done = false;
while(next(funcIndex-1)) {
if(isFunction()) {
// repush arguments
for(int i=0;i<numArgs;++i)
pushValue(-numArgs-2);
int rets = safeCall(numArgs);
if(rets == 1) {
done = popBoolean();
if(done) {
pop();
break;
}
} else if(rets != 0)
throw LuaException("function call didn't return the expected number of results", 0);
} else {
throw LuaException("attempt to call a non function", 0);
}
}
pop(numArgs + 1); // pops the table of function and arguments
if(numRets == 1 || numRets == -1) {
rets = 1;
pushBoolean(done);
}
}
// nil values are ignored
else if(isNil(funcIndex)) {
pop(numArgs + 1); // pops the function and arguments
}
// if not nil, warn
else {
throw LuaException("attempt to call a non function value", 0);
}
} catch(stdext::exception& e) {
g_logger.error(stdext::format("protected lua call failed: %s", e.what()));
}
// pushes nil values if needed
while(numRets != -1 && rets < numRets) {
pushNil();
rets++;
}
// returns the number of results on the stack
return rets;
}
开发者ID:Ablankzin,项目名称:otclient,代码行数:67,代码来源:luainterface.cpp
注:本文中的pushBoolean函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论