• “黑神话·悟空”免安装在线玩,无视显卡等硬件要求!!
  • √ 游戏免下载安装 √ 5分钟随开随玩 √ 关机不计费!低至¥14.90/月!
🔥进入竞技-直面天命🔥

static int ForEachMob(lua_State* L) {

时间2023-03-22 23:47:19 提问来自 上海市上海市 的网友 分类创作 浏览314
lua_pushnil(L); while (lua_next(L, -2) != 0) { if (lua_isuserdata(L, -1)) { Mob* mob = static_cast<Mob*>(lua_touserdata(L, -1)); if (mob != nullptr && lua_pcall(L, 1, 0, 0) != 0) { #if defined(_DEBUG) || defined(_EQDEBUG) Log.Out(Logs::General, Logs::Lua, "Error running ForEachMob iterator function: %s", lua_tostring(L,-1)); //error message should be on top of the stack from lua. if its not print a general error. Shouldn't happen unless there is an actual bug in Lua code. #endif lua_pop(L,-1);//pop the error msg from the stack since we are not going to propagate it back up to C code. The Lua code needs to handle it itself if its gonna handle errors at all. } } else { //not a Mob object so skip it and leave it on the stack for next iteration of loop to find. This could happen if someone passed something other than a Mob object into this function call in Lua land ie: ForEachMob({}) or something like that.. lua_pop(L,-1);//Remove value but keep key for next iteration } }//end while loop over table elements return 0;//no return values.. all work done by side effect of iter func call above... }

点击这里,进行内容创作

创作工场 免责声明:
以上内容除特别注明外均来源于网友提问,创作工场回答,未经许可,严谨转载。
点击这里>>使用🔥专业版,更聪明、更完整、更原创!

上一篇 static int ForEachMob(lua_State* L) { 下一篇 大学机械设计现场认知实验的目的