Changeset 11662 for code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/scriptable_controller.cc
- Timestamp:
- Dec 11, 2017, 4:35:38 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/scriptable_controller.cc
r11638 r11662 35 35 if((ret = luaL_loadfile(lua, file_path.c_str())) != 0) 36 36 { 37 orxout(user_error) << "Failed to load level script " + file_path << std::endl; 37 38 this->printLuaError(lua); 38 39 delete api; … … 43 44 if((ret = lua_pcall(lua, 0, LUA_MULTRET, 0)) != 0) 44 45 { 46 orxout(user_error) << "Level script returned an error" << std::endl; 45 47 this->printLuaError(lua); 46 48 delete api; … … 86 88 87 89 for(auto &api : this->apis_) 88 api->pawnKilled(pawn_id_iter->second );90 api->pawnKilled(pawn_id_iter->second, pawn); 89 91 90 92 this->pawns_.erase(pawn_id_iter->second); … … 110 112 void ScriptableController::killPawn(std::string id) 111 113 { 112 auto pawn = this-> pawns_.find(id);113 if(pawn == this->pawns_.end())114 auto pawn = this->getPawnByID(id); 115 if(pawn == nullptr) 114 116 { 115 117 orxout(user_warning) << "Tried to destroy unknown pawn " << id << std::endl; … … 117 119 } 118 120 119 pawn-> second->kill();121 pawn->kill(); 120 122 } 121 123 … … 141 143 Pawn *ScriptableController::getPawnByID(std::string id) const 142 144 { 145 if(id == "player" || id == "Player" || id == "PLAYER") 146 return orxonox_cast<Pawn*>(this->player_->getControllableEntity()); 147 143 148 auto pawn = this->pawns_.find(id); 144 149 return pawn != this->pawns_.end() ? pawn->second : nullptr; … … 151 156 // Yes, this is 'const char*' and not 'std::string' because that's what lua gives us. 152 157 const char* message = lua_tostring(lua, -1); 153 std::cout<< message << std::endl;158 orxout(user_error) << message << std::endl; 154 159 lua_pop(lua, 1); 155 160 }
Note: See TracChangeset
for help on using the changeset viewer.