Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8289 in orxonox.OLD


Ignore:
Timestamp:
Jun 8, 2006, 7:43:10 PM (18 years ago)
Author:
snellen
Message:

added some debug output, script gets called

Location:
branches/script_engine/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/script_engine/src/lib/script_engine/script.cc

    r8271 r8289  
    2323  luaopen_math(luaState);
    2424  luaopen_debug(luaState);
    25 
    2625  if (root != NULL)
    2726    this->loadParams(root);
     
    7776     else
    7877     {
    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());
    8586     reportError(error);
    8687   }
     
    9293 void Script::addObject(const std::string& className, const std::string& objectName)
    9394 {
     95   printf("Script: I am about to add %s of class %s\n",objectName.c_str(),className.c_str());
     96   
    9497   BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS);
    9598   WorldObject tmpObj;
     
    162165    if(error != 0)
    163166    {
     167     printf("ERROR while executing function %s: \n",currentFunction.c_str());
    164168     reportError(error);
     169     //clean up
     170     currentFunction.assign("");
     171     argumentCount = returnCount = 0;
    165172     return false;
    166173    }
     
    174181   else
    175182     printf("Error: no function selected.\n");
     183   
     184   return false;
    176185 }
    177186
     
    296305  fprintf(stderr, "ERROR: %s\n", msg);
    297306  lua_pop(luaState, 1);
     307 }
    298308  return error;
    299309 }
    300  }
    301310
    302311
  • branches/script_engine/src/lib/script_engine/script_class.h

    r8271 r8289  
    6161    virtual int insertObject(Script* L, BaseObject* obj, bool gc=false)
    6262    {
    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);
    6464    }
    6565
  • branches/script_engine/src/lib/script_engine/script_manager.cc

    r8285 r8289  
    11#include <string>
    22#include <list>
     3
     4#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD
    35
    46
     
    1921{
    2022  this->setName("ScriptManager");
    21   printf("ScriptManager created\n");
    2223  this->scripts = NULL;
    2324  this->triggers = NULL;
     
    7475  LOAD_PARAM_START_CYCLE(triggers, object);
    7576  {
    76     new ScriptTrigger(object);PRINTF(0)("test output from createtriggers\n");
     77    new ScriptTrigger(object);
    7778  }
    7879  LOAD_PARAM_END_CYCLE(object);
  • branches/script_engine/src/story_entities/game_world.cc

    r8271 r8289  
    137137  PhysicsEngine::getInstance();
    138138  CREngine::getInstance();
     139 
     140  State::setScriptManager(&this->scriptManager);
     141
    139142}
    140143
     
    146149ErrorMessage GameWorld::loadData()
    147150{
    148   this->displayLoadScreen();
     151  this->displayLoadScreen();  State::setScriptManager(&this->scriptManager);
     152
    149153
    150154  PRINTF(0)("Loading the GameWorld\n");
     
    189193  Account *b = new Account(30);
    190194  b->setName("b");
    191  
     195  printf("ScriptManager created by game world\n");
    192196  LoadParamXML(root, "ScriptManager", &this->scriptManager, ScriptManager, loadParams);
    193197
     
    229233  this->bRunning = true;
    230234
    231   State::setScripManager(&this->scriptManager);
    232 
    233235  this->run();
    234236}
     
    241243{
    242244  PRINTF(3)("GameWorld::stop() - got stop signal\n");
    243   State::setScripManager(NULL);
     245  State::setScriptManager(NULL);
    244246  this->bRunning = false;
    245247}
  • branches/script_engine/src/util/state.h

    r8271 r8289  
    9696
    9797  ////////////////////
    98   /// SCRIP_ENGINE ///
     98  /// SCRIPT_ENGINE ///
    9999  ////////////////////
    100   static void setScripManager(ScriptManager* scriptManager) { State::scriptManager = scriptManager; };
     100  static void setScriptManager(ScriptManager* scriptManager) { State::scriptManager = scriptManager; };
    101101  static ScriptManager* getScriptManager() { return State::scriptManager; };
    102102
  • branches/script_engine/src/world_entities/script_trigger.cc

    r8286 r8289  
    1818  loadParams(root);
    1919
    20   printf("scripttrigger generated\n");
    2120}
    2221
     
    9594  if( this->distance(target) < radius)
    9695 {
    97    printf("SCRIPTTRIGGER: condition met\n");
    9896  if(!callOnce)
    9997   {
     
    102100  else if(callOnce && !scriptCalled)
    103101  {
    104     printf("action should be executed\n");
    105102   executeAction();
    106103   scriptCalled = true;
    107104  }
    108105 }
    109  else
    110    printf("SCRIPTTRIGGER: target out of range\n");
     106 //else
     107   //printf("SCRIPTTRIGGER: target out of range\n");
    111108
    112109}
     
    118115     {
    119116       testScriptingFramework();
    120      if(!(script->selectFunction(this->functionName,0)) )
     117     /*if(!(script->selectFunction(this->functionName,0)) )
    121118       printf("Error ScriptTrigger: Selection of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
    122119     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());*/
    124121     }
    125122}
     
    128125void ScriptTrigger::setScript(const std::string& file)
    129126{
     127 
    130128  ScriptManager* scriptManager = State::getScriptManager();
    131129  if (scriptManager != NULL)
    132130  {
     131   
    133132    script = scriptManager->getScriptByFile(file);
    134133    if(script != NULL)
     134    {
    135135      scriptIsOk = true;
     136    }
    136137  }
    137138}
     
    173174
    174175   script->pushParam(3.14159,main);
     176   printf("-------------------------- top of the stack:%i\n",lua_gettop(script->getLuaState()));
    175177   script->executeFunction();
    176178
     
    187189   printf("main returned %i\n",ret);
    188190
    189       //printf("-------------------------- top of the stack:%i\n",lua_gettop(script.getLuaState()));
     191   printf("-------------------------- top of the stack:%i\n",lua_gettop(script->getLuaState()));
    190192      //execute a 2nd function
    191193   printf("----------- test -----------\n");
Note: See TracChangeset for help on using the changeset viewer.