Changeset 8711 in orxonox.OLD for trunk/src/lib/script_engine/script.cc
- Timestamp:
- Jun 22, 2006, 1:09:20 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/script_engine/script.cc
r8408 r8711 1 /* 2 orxonox - the future of 3D-vertical-scrollers 3 4 Copyright (C) 2004 orx 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 11 ### File Specific: 12 main-programmer: Silvan Nellen 13 co-programmer: Benjamin Grauer 14 */ 15 1 16 #include "script.h" 2 17 #include "script_class.h" 3 18 #include "luaincl.h" 4 19 20 #include "util/loading/resource_manager.h" 5 21 6 22 #include "loading/load_param.h" … … 58 74 { 59 75 76 std::string filedest(ResourceManager::getInstance()->getDataDir()); 77 filedest += "scripts/" + filename; 78 60 79 if(currentFile.length() != 0) 61 80 { … … 64 83 } 65 84 66 int error = luaL_loadfile (luaState, file name.c_str());85 int error = luaL_loadfile (luaState, filedest.c_str()); 67 86 68 87 if(error == 0) 69 88 { 89 70 90 error = lua_pcall(luaState, 0, 0, 0); 71 91 … … 192 212 bool Script::pushParam(int param, std::string& toFunction) 193 213 { 194 if(currentFunction .compare(toFunction) == 0)214 if(currentFunction == toFunction) 195 215 { 196 216 lua_pushnumber(luaState, (lua_Number) param); 197 217 argumentCount++; 198 return true;218 return true; 199 219 } 200 220 else … … 267 287 returnCount--; 268 288 } 289 else 290 printf("ERROR: Form %s : trying to retreive non bolean value",this->currentFile.c_str()); 269 291 } 270 292 return returnValue; … … 313 335 } 314 336 337 bool Script::registerStandartClasses() 338 { 339 bool success = false; 340 341 //success = this->registerClass(std::string("Vector")); 342 343 return success; 344 } 345 346 347 bool Script::registerClass( const std::string& className) 348 { 349 BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS); 350 //printf("The script class for %s is at %p \n",className.c_str(),scriptClass); 351 WorldObject tmpObj; 352 if (scriptClass != NULL) 353 { 354 tmpObj.type = className; 355 if( !classIsRegistered(className) ) 356 { 357 static_cast<ScriptClass*>(scriptClass)->registerClass(this); 358 tmpObj.name = ""; 359 registeredObjects.push_back(tmpObj); 360 return true; 361 } 362 } 363 return false; 364 365 } 315 366 316 367 bool Script::classIsRegistered(const std::string& type)
Note: See TracChangeset
for help on using the changeset viewer.