/* function: StringToMobType */ static int tolua_AllToLua_StringToMobType00(lua_State* tolua_S) { cLuaState LuaState(tolua_S); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_iscppstring(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { const AString a_MobString = tolua_tocppstring(LuaState, 1, 0); eMonsterType MobType = cMonster::StringToMobType(a_MobString); tolua_pushnumber(LuaState, (lua_Number) MobType); tolua_pushcppstring(LuaState, (const char *) a_MobString); } LOGWARNING("Warning in function call 'StringToMobType': StringToMobType() is deprecated. Please use cMonster:StringToMobType()"); LuaState.LogStackTrace(0); return 2; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(LuaState, "#ferror in function 'StringToMobType'.", &tolua_err); return 0; #endif }
/** function: cWorld:SetSignLines */ static int tolua_cWorld_SetSignLines(lua_State * tolua_S) { cLuaState LuaState(tolua_S); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype (LuaState, 1, "cWorld", 0, &tolua_err) || !tolua_isnumber (LuaState, 2, 0, &tolua_err) || !tolua_isnumber (LuaState, 3, 0, &tolua_err) || !tolua_isnumber (LuaState, 4, 0, &tolua_err) || !tolua_iscppstring(LuaState, 5, 0, &tolua_err) || !tolua_iscppstring(LuaState, 6, 0, &tolua_err) || !tolua_iscppstring(LuaState, 7, 0, &tolua_err) || !tolua_iscppstring(LuaState, 8, 0, &tolua_err) || !tolua_isusertype (LuaState, 9, "cPlayer", 1, &tolua_err) || !tolua_isnoobj (LuaState, 10, &tolua_err) ) goto tolua_lerror; else #endif { cWorld * self = (cWorld *) tolua_tousertype (LuaState, 1, nullptr); int BlockX = (int) tolua_tonumber (LuaState, 2, 0); int BlockY = (int) tolua_tonumber (LuaState, 3, 0); int BlockZ = (int) tolua_tonumber (LuaState, 4, 0); const AString Line1 = tolua_tocppstring(LuaState, 5, 0); const AString Line2 = tolua_tocppstring(LuaState, 6, 0); const AString Line3 = tolua_tocppstring(LuaState, 7, 0); const AString Line4 = tolua_tocppstring(LuaState, 8, 0); cPlayer * Player = (cPlayer *)tolua_tousertype (LuaState, 9, nullptr); #ifndef TOLUA_RELEASE if (self == nullptr) { tolua_error(LuaState, "invalid 'self' in function 'UpdateSign'", nullptr); } #endif { bool res = self->SetSignLines(BlockX, BlockY, BlockZ, Line1, Line2, Line3, Line4, Player); tolua_pushboolean(LuaState, res ? 1 : 0); } } LOGWARNING("Warning in function call 'UpdateSign': UpdateSign() is deprecated. Please use SetSignLines()"); LuaState.LogStackTrace(0); return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(LuaState, "#ferror in function 'UpdateSign'.", &tolua_err); return 0; #endif }
lua::LuaState lua::LuaStack::NewThread() { return LuaState( lua_newthread(m_state) ); }
lua::LuaState lua::LuaStack::State() const { return LuaState( m_state ); }
ScriptManager::ScriptManager() :ls(LuaState()) { //ctor }
void LuaActivity::eventProduced(EventDetails* const details, UInt32 producedEventId) { if(!getCode().empty()) { //Run my Code if(LuaManager::the()->runScript(getCode()) != 0) { //Failed to run the script return; } } //If there is an entry function then call it if(!getEntryFunction().empty()) { //Get the Lua state lua_State *LuaState(LuaManager::the()->getLuaState()); //Get the Lua function to be called for(UInt32 i(0) ; i<_EntryFunctionPath.size() ; ++i) { if(i == 0) { lua_pushstring(LuaState,_EntryFunctionPath[i].c_str()); //push the name of the table on the stack lua_gettable(LuaState, LUA_GLOBALSINDEX); //Push The table onto the stack } else { //Check if the the value given is a table if(!lua_istable(LuaState, -1)) { lua_pop(LuaState, 1); //Pop the value off the stack std::string TablePath(""); for(UInt32 j(0) ; j<i ; ++j) { if(j!=0) TablePath += "."; TablePath += _EntryFunctionPath[j]; } SWARNING << TablePath << " cannot be referenced in lua because it is not a table" << std::endl; return; } lua_pushstring(LuaState,_EntryFunctionPath[i].c_str()); //push the name of the table on the stack lua_gettable(LuaState, -2); //Push The table onto the stack //Remove the original table from the stack lua_remove(LuaState, -2); } } //Check if the the value given is a function if(!lua_isfunction(LuaState, -1)) { lua_pop(LuaState, 1); //Pop the value off the stack SWARNING << getEntryFunction() << " cannot be referenced in lua because it is not a function" << std::endl; return; } //Push on the arguments push_FieldContainer_on_lua(LuaState, details); //Argument 1: the EventUnrecPtr lua_pushnumber(LuaState,producedEventId); //Argument 2: the ProducedEvent ID //Execute the Function // |------2 arguments to function // | // | |---0 arguments returned // | | // V V LuaManager::the()->runPushedFunction(2, 0); } }