Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 30, 2009, 2:10:44 PM (15 years ago)
Author:
rgrieder
Message:

Merged resource branch back to the trunk. Changes:

  • Automated graphics loading by evaluating whether a GameState requires it
  • Using native Tcl library (x3n)

Windows users: Update your dependency package!

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/core/LuaBind.cc

    r3301 r3370  
    3939#include "util/Debug.h"
    4040#include "util/StringUtils.h"
    41 #include "ToluaBindCore.h"
    4241#include "Core.h"
    4342
    4443namespace orxonox
    4544{
    46   LuaBind* LuaBind::singletonRef_s = NULL;
     45  LuaBind* LuaBind::singletonPtr_s = NULL;
    4746
    4847  LuaBind::LuaBind()
    4948  {
    50     assert(LuaBind::singletonRef_s == 0);
    51     LuaBind::singletonRef_s = this;
    52 
    5349    this->includePath_ = Core::getMediaPathString();
    5450
     
    6561    luaopen_debug(luaState_);
    6662#endif
    67     tolua_Core_open(luaState_);
     63
     64    // Open all available tolua interfaces
     65    this->openToluaInterfaces(luaState_);
     66
    6867    output_ = "";
    6968    isRunning_ = false;
    7069  }
     70
     71  LuaBind::~LuaBind()
     72  {
     73    this->closeToluaInterfaces(luaState_);
     74  };
    7175
    7276  void LuaBind::luaPrint(const std::string& str)
     
    315319  }
    316320
     321  void LuaBind::addToluaInterface(int (*function)(lua_State*), const std::string& name)
     322  {
     323    toluaInterfaces_.push_back(std::make_pair(name, function));
     324    // Apply changes to our own lua state as well
     325    (*function)(luaState_);
     326  }
     327
     328  void LuaBind::openToluaInterfaces(lua_State* state)
     329  {
     330    for (unsigned int i = 0; i < toluaInterfaces_.size(); ++i)
     331      (*toluaInterfaces_[i].second)(state);
     332  }
     333
     334  void LuaBind::closeToluaInterfaces(lua_State* state)
     335  {
     336    for (unsigned int i = 0; i < toluaInterfaces_.size(); ++i)
     337    {
     338      lua_pushnil(state);
     339      lua_setglobal(state, toluaInterfaces_[i].first.c_str());
     340    }
     341  }
     342
    317343}
Note: See TracChangeset for help on using the changeset viewer.