Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 6, 2008, 2:43:12 AM (16 years ago)
Author:
bknecht
Message:

some changes with the script. Made it singleton plus the files were moved into the core.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • code/branches/script/src/orxonox/core/Script.cc

    r996 r999  
    3939
    4040#include "tolua++.h"
    41 #include "tolua_script.h"
     41#include "toluabind.h"
    4242
    4343namespace orxonox
    4444{
    4545
    46   lua_State* Script::luaState_ = lua_open();
    47   //lua_State* Script::luaState_ = NULL;
    48   std::string Script::fileString_ = "";
    49 
    5046  Script::Script()
    5147  {
    52   }
    53 
    54   Script::~Script()
    55   {
    56 
    57   }
    58 
    59   /**
    60       @brief Initializes a lua state
    61       @param state_ the pointer of the lua_state to initialise
    62   */
    63   void Script::init(lua_State *state_)
    64   {
    65     tolua_script_open(state_);
    66 
    67     /*
    68 #if LUA_VERSION_NUM == 501
    69     luaL_openlibs(state_);
    70 #else
    71     luaopen_base(state_);
    72     luaopen_table(state_);
    73     luaopen_io(state_);
    74     luaopen_string(state_);
    75     luaopen_math(state_);
    76     luaopen_debug(state_);
    77 #endif
    78     */
     48    luaState_ = lua_open();
     49    luaSource_ = "";
     50    tolua_something_open(luaState_);
    7951  }
    8052
    8153  void Script::luaPrint(std::string str)
    8254  {
    83     fileString_ = str;
     55    output_ = str;
    8456  }
    8557
     
    10072
    10173    char line[1024];
     74    std::string levelString = "";
    10275
    10376    while (file.good() && !file.eof())
    10477    {
    10578      file.getline(line, 1024);
    106       fileString_ += line;
     79      levelString += line;
    10780    }
    10881
     
    11083    //std::string output;
    11184
    112     if (luaTags) fileString_ = replaceLuaTags(Script::fileString_);
     85    if (luaTags) luaSource_ = replaceLuaTags(levelString);
    11386  }
    11487
     
    11790    int error = 0;
    11891    std::string init = "local scr = orxonox.Script:new()\n";
    119     init += fileString_;
     92    init += luaSource_;
    12093    error = luaL_loadstring(luaState_, init.c_str());
    12194    if (error == 0)
Note: See TracChangeset for help on using the changeset viewer.