Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10381 in orxonox.OLD for trunk/src/lib/script_engine/script.cc


Ignore:
Timestamp:
Jan 26, 2007, 5:29:26 PM (17 years ago)
Author:
patrick
Message:

merged script branche to turnk

File:
1 edited

Legend:

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

    r10321 r10381  
    111111   if(currentFile.length() != 0)
    112112   {
    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());
    114114     return false;
    115115    }
     
    119119   if(error == 0)
    120120   {
    121      currentFile = filename;
     121     currentFile = file;
    122122     error = lua_pcall(luaState, 0, 0, 0);
    123123
     
    128128     else
    129129     {
    130        printf("SCRIPT %s : ERROR: while loading file %s: \n",currentFile.c_str(),filename.c_str());
    131130       reportError(error);
    132131     }
     
    135134   else
    136135   {
    137      printf("SCRIPT %s : ERROR: while loading file %s: \n",currentFile.c_str(),filename.c_str());
    138136     reportError(error);
    139137   }
    140138
    141    printf("SCRIPT : ERROR: while loading file %s \n",filename.c_str());
     139   printf("ERROR IN SCRIPT:  Could not load file %s \n",filename.c_str());
    142140   return false;
    143141 }
     
    166164        tmpObj.name = objectName;
    167165        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
     173void 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 }
    172195
    173196
     
    208231   }
    209232   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());
    211234   return false;
    212235 }
     
    235258   }
    236259   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());
    238261
    239262   return false;
     
    252275   else
    253276   {
    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());
    255278    return false;
    256279   }
     
    269292   else
    270293   {
    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());
    272295     return false;
    273296   }
     
    285308   else
    286309   {
    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());
    288311     return false;
    289312   }
     
    320343     }
    321344     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());
    323346   }
    324347   return returnValue;
     
    373396  const char *msg = lua_tostring(luaState, -1);
    374397  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);
    376399  lua_pop(luaState, 1);
    377400 }
Note: See TracChangeset for help on using the changeset viewer.