Changeset 10381 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Jan 26, 2007, 5:29:26 PM (18 years ago)
- Location:
- trunk/src/lib/script_engine
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/script_engine/script.cc
r10321 r10381 111 111 if(currentFile.length() != 0) 112 112 { 113 printf(" SCRIPT %s : ERROR:Could not load %s because an other file is already loaded: %s\n",currentFile.c_str(),filename.c_str(), currentFile.c_str());113 printf("ERROR IN SCRIPT %s : Could not load %s because an other file is already loaded: %s\n",currentFile.c_str(),filename.c_str(), currentFile.c_str()); 114 114 return false; 115 115 } … … 119 119 if(error == 0) 120 120 { 121 currentFile = file name;121 currentFile = file; 122 122 error = lua_pcall(luaState, 0, 0, 0); 123 123 … … 128 128 else 129 129 { 130 printf("SCRIPT %s : ERROR: while loading file %s: \n",currentFile.c_str(),filename.c_str());131 130 reportError(error); 132 131 } … … 135 134 else 136 135 { 137 printf("SCRIPT %s : ERROR: while loading file %s: \n",currentFile.c_str(),filename.c_str());138 136 reportError(error); 139 137 } 140 138 141 printf(" SCRIPT : ERROR: while loadingfile %s \n",filename.c_str());139 printf("ERROR IN SCRIPT: Could not load file %s \n",filename.c_str()); 142 140 return false; 143 141 } … … 166 164 tmpObj.name = objectName; 167 165 registeredObjects.push_back(tmpObj); 168 } 169 } 170 } 171 166 return; 167 } 168 } 169 printf("ERROR IN SCRIPT %s: Could not add %s of class %s\n",this->currentFile.c_str(),objectName.c_str(),className.c_str()); 170 } 171 172 173 void Script::addObjectAsName( const std::string& className, const std::string& objectName, const std::string& nameInScript) 174 { 175 ScriptClass* scriptClass = ScriptClass::objectList().getObject(className); 176 WorldObject tmpObj; 177 if (scriptClass != NULL) 178 { 179 tmpObj.type = className; 180 if( !classIsRegistered(className) ) 181 { 182 scriptClass->registerClass(this); 183 } 184 BaseObject* object = ObjectListBase::getBaseObject(className, objectName); 185 if (object != NULL && !objectIsAdded(objectName)) 186 { 187 scriptClass->insertObject(this, object,nameInScript, false); 188 tmpObj.name = objectName; 189 registeredObjects.push_back(tmpObj); 190 return; 191 } 192 } 193 printf("ERROR IN SCRIPT %s: Could not add %s of class %s\n",this->currentFile.c_str(),objectName.c_str(),className.c_str()); 194 } 172 195 173 196 … … 208 231 } 209 232 else 210 printf(" SCRIPT %s : ERROR:There is an other function active ( %s ) or there are unremoved return values on the stack. Please remove them first.\n",currentFile.c_str(),currentFunction.c_str());233 printf("ERROR IN SCRIPT %s : There is an other function active ( %s ) or there are unremoved return values on the stack. Please remove them first.\n",currentFile.c_str(),currentFunction.c_str()); 211 234 return false; 212 235 } … … 235 258 } 236 259 else 237 PRINTF(1)("SCRIPT '%s' : no function selected.\n",currentFile.c_str());260 PRINTF(1)("SCRIPT '%s' : No function selected.\n",currentFile.c_str()); 238 261 239 262 return false; … … 252 275 else 253 276 { 254 printf(" SCRIPT %s : ERROR:Couldn't add parameter because the wrong function is selected: %s instead of %s\n",currentFile.c_str(), currentFunction.c_str(), toFunction.c_str());277 printf("ERROR IN SCRIPT %s : Couldn't add parameter because the wrong function is selected: %s instead of %s\n",currentFile.c_str(), currentFunction.c_str(), toFunction.c_str()); 255 278 return false; 256 279 } … … 269 292 else 270 293 { 271 printf(" SCRIPT %s : ERROR:Couldn't add parameter because the wrong function is selected: %s instead of %s\n",currentFile.c_str(), currentFunction.c_str(), toFunction.c_str());294 printf("ERROR IN SCRIPT %s : Couldn't add parameter because the wrong function is selected: %s instead of %s\n",currentFile.c_str(), currentFunction.c_str(), toFunction.c_str()); 272 295 return false; 273 296 } … … 285 308 else 286 309 { 287 printf(" SCRIPT %s : ERROR:Couldn't add parameter because the wrong function is selected: %s instead of %s\n",currentFile.c_str(), currentFunction.c_str(), toFunction.c_str());310 printf("ERROR IN SCRIPT %s : Couldn't add parameter because the wrong function is selected: %s instead of %s\n",currentFile.c_str(), currentFunction.c_str(), toFunction.c_str()); 288 311 return false; 289 312 } … … 320 343 } 321 344 else 322 printf(" SCRIPT %s : ERROR:Trying to retreive non bolean value\n",this->currentFile.c_str());345 printf("ERROR IN SCRIPT %s : Trying to retreive non bolean value\n",this->currentFile.c_str()); 323 346 } 324 347 return returnValue; … … 373 396 const char *msg = lua_tostring(luaState, -1); 374 397 if (msg == NULL) msg = "(error with no message)\n"; 375 printf("ERROR : %s\n", msg);398 printf("ERROR IN SCRIPT %s : %s\n",currentFile.c_str(), msg); 376 399 lua_pop(luaState, 1); 377 400 } -
trunk/src/lib/script_engine/script.h
r9869 r10381 34 34 bool loadFile(const std::string& filename); 35 35 void addObject( const std::string& className,const std::string& objectName); 36 void addObjectAsName( const std::string& className,const std::string& objectName, const std::string& nameInScript); 36 37 void registerClass(const std::string& className); //!< Register a class but dont add any instances 37 38 -
trunk/src/lib/script_engine/script_class.cc
r9916 r10381 25 25 CREATE_SCRIPTABLE_CLASS(Script, 26 26 addMethod("addObject", Executor2<Script, lua_State*,const std::string&, const std::string& >(&Script::addObject)) 27 ->addMethod("addObjectAsName", Executor3<Script, lua_State*,const std::string&, const std::string&, const std::string& >(&Script::addObjectAsName)) 27 28 ->addMethod("registerClass", Executor1<Script, lua_State*,const std::string&>(&Script::registerClass)) 28 29 ->addMethod("selectFunction", Executor2ret<Script, lua_State*, bool, const std::string&, int >(&Script::selectFunction))
Note: See TracChangeset
for help on using the changeset viewer.