- Timestamp:
- Jun 8, 2006, 7:43:10 PM (18 years ago)
- Location:
- branches/script_engine/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/lib/script_engine/script.cc
r8271 r8289 23 23 luaopen_math(luaState); 24 24 luaopen_debug(luaState); 25 26 25 if (root != NULL) 27 26 this->loadParams(root); … … 77 76 else 78 77 { 79 reportError(error); 80 } 81 82 } 83 else 84 { 78 printf("ERROR while loading file %s: ",filename.c_str()); 79 reportError(error); 80 } 81 82 } 83 else 84 { 85 printf("ERROR while loading file %s: ",filename.c_str()); 85 86 reportError(error); 86 87 } … … 92 93 void Script::addObject(const std::string& className, const std::string& objectName) 93 94 { 95 printf("Script: I am about to add %s of class %s\n",objectName.c_str(),className.c_str()); 96 94 97 BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS); 95 98 WorldObject tmpObj; … … 162 165 if(error != 0) 163 166 { 167 printf("ERROR while executing function %s: \n",currentFunction.c_str()); 164 168 reportError(error); 169 //clean up 170 currentFunction.assign(""); 171 argumentCount = returnCount = 0; 165 172 return false; 166 173 } … … 174 181 else 175 182 printf("Error: no function selected.\n"); 183 184 return false; 176 185 } 177 186 … … 296 305 fprintf(stderr, "ERROR: %s\n", msg); 297 306 lua_pop(luaState, 1); 307 } 298 308 return error; 299 309 } 300 }301 310 302 311 -
branches/script_engine/src/lib/script_engine/script_class.h
r8271 r8289 61 61 virtual int insertObject(Script* L, BaseObject* obj, bool gc=false) 62 62 { 63 Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), obj->getName(), gc);63 return Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), obj->getName(), gc); 64 64 } 65 65 -
branches/script_engine/src/lib/script_engine/script_manager.cc
r8285 r8289 1 1 #include <string> 2 2 #include <list> 3 4 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD 3 5 4 6 … … 19 21 { 20 22 this->setName("ScriptManager"); 21 printf("ScriptManager created\n");22 23 this->scripts = NULL; 23 24 this->triggers = NULL; … … 74 75 LOAD_PARAM_START_CYCLE(triggers, object); 75 76 { 76 new ScriptTrigger(object); PRINTF(0)("test output from createtriggers\n");77 new ScriptTrigger(object); 77 78 } 78 79 LOAD_PARAM_END_CYCLE(object); -
branches/script_engine/src/story_entities/game_world.cc
r8271 r8289 137 137 PhysicsEngine::getInstance(); 138 138 CREngine::getInstance(); 139 140 State::setScriptManager(&this->scriptManager); 141 139 142 } 140 143 … … 146 149 ErrorMessage GameWorld::loadData() 147 150 { 148 this->displayLoadScreen(); 151 this->displayLoadScreen(); State::setScriptManager(&this->scriptManager); 152 149 153 150 154 PRINTF(0)("Loading the GameWorld\n"); … … 189 193 Account *b = new Account(30); 190 194 b->setName("b"); 191 195 printf("ScriptManager created by game world\n"); 192 196 LoadParamXML(root, "ScriptManager", &this->scriptManager, ScriptManager, loadParams); 193 197 … … 229 233 this->bRunning = true; 230 234 231 State::setScripManager(&this->scriptManager);232 233 235 this->run(); 234 236 } … … 241 243 { 242 244 PRINTF(3)("GameWorld::stop() - got stop signal\n"); 243 State::setScrip Manager(NULL);245 State::setScriptManager(NULL); 244 246 this->bRunning = false; 245 247 } -
branches/script_engine/src/util/state.h
r8271 r8289 96 96 97 97 //////////////////// 98 /// SCRIP _ENGINE ///98 /// SCRIPT_ENGINE /// 99 99 //////////////////// 100 static void setScrip Manager(ScriptManager* scriptManager) { State::scriptManager = scriptManager; };100 static void setScriptManager(ScriptManager* scriptManager) { State::scriptManager = scriptManager; }; 101 101 static ScriptManager* getScriptManager() { return State::scriptManager; }; 102 102 -
branches/script_engine/src/world_entities/script_trigger.cc
r8286 r8289 18 18 loadParams(root); 19 19 20 printf("scripttrigger generated\n");21 20 } 22 21 … … 95 94 if( this->distance(target) < radius) 96 95 { 97 printf("SCRIPTTRIGGER: condition met\n");98 96 if(!callOnce) 99 97 { … … 102 100 else if(callOnce && !scriptCalled) 103 101 { 104 printf("action should be executed\n");105 102 executeAction(); 106 103 scriptCalled = true; 107 104 } 108 105 } 109 else110 printf("SCRIPTTRIGGER: target out of range\n");106 //else 107 //printf("SCRIPTTRIGGER: target out of range\n"); 111 108 112 109 } … … 118 115 { 119 116 testScriptingFramework(); 120 if(!(script->selectFunction(this->functionName,0)) )117 /*if(!(script->selectFunction(this->functionName,0)) ) 121 118 printf("Error ScriptTrigger: Selection of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str()); 122 119 if( !(script->executeFunction()) ) 123 printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str()); 120 printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());*/ 124 121 } 125 122 } … … 128 125 void ScriptTrigger::setScript(const std::string& file) 129 126 { 127 130 128 ScriptManager* scriptManager = State::getScriptManager(); 131 129 if (scriptManager != NULL) 132 130 { 131 133 132 script = scriptManager->getScriptByFile(file); 134 133 if(script != NULL) 134 { 135 135 scriptIsOk = true; 136 } 136 137 } 137 138 } … … 173 174 174 175 script->pushParam(3.14159,main); 176 printf("-------------------------- top of the stack:%i\n",lua_gettop(script->getLuaState())); 175 177 script->executeFunction(); 176 178 … … 187 189 printf("main returned %i\n",ret); 188 190 189 //printf("-------------------------- top of the stack:%i\n",lua_gettop(script.getLuaState()));191 printf("-------------------------- top of the stack:%i\n",lua_gettop(script->getLuaState())); 190 192 //execute a 2nd function 191 193 printf("----------- test -----------\n");
Note: See TracChangeset
for help on using the changeset viewer.