Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 19, 2008, 11:46:37 PM (16 years ago)
Author:
rgrieder
Message:

Merged script_trigger branch into objecthierarchy branch.
Also merged changes in Script.cc and Script.h manually to LuaBind.cc and LuaBind.h.

Location:
code/branches/objecthierarchy
Files:
2 deleted
6 edited
8 copied

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy

  • code/branches/objecthierarchy/src/core/CMakeLists.txt

    r1887 r1959  
    66  GameState.cc
    77  Language.cc
     8  Luabind.cc
    89  ObjectListBase.cc
    910  OrxonoxClass.cc
    1011  RootGameState.cc
    11   Script.cc
    1212
    1313  # command
     
    6262    tolua_orxonox
    6363    tolua/tolua.pkg
    64     Script.h
     64    LuaBind.h
    6565    CommandExecutor.h
    6666  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
  • code/branches/objecthierarchy/src/core/Loader.cc

    r1755 r1959  
    3434#include "ObjectList.h"
    3535#include "CoreIncludes.h"
    36 #include "Script.h"
     36#include "LuaBind.h"
    3737#include "Namespace.h"
    3838#include "util/Debug.h"
     
    119119
    120120        // let Lua work this out:
    121         //Script* lua;
    122         /*Script::loadFile(level->getFile(), true);
    123         Script::init(Script::getLuaState());
    124         Script::run();*/
    125         Script* lua = Script::getInstance();
     121        LuaBind* lua = LuaBind::getInstance();
    126122        lua->clearLuaOutput();
    127123        lua->loadFile(level->getFile(), true);
  • code/branches/objecthierarchy/src/core/LuaBind.cc

    • Property svn:eol-style set to native
    r1954 r1959  
    3232#include <map>
    3333
    34 #include "CoreIncludes.h"
    35 
    36 extern "C" {
    37 #include <lualib.h>
    38 #include <lauxlib.h>
    39 }
    40 
     34#include "lua/lua.hpp"
    4135#include "tolua/tolua++.h"
    4236#include "tolua/tolua_bind.h"
     37#include "util/String.h"
     38#include "CoreIncludes.h"
    4339
    4440namespace orxonox
     
    6056    luaopen_debug(luaState_);
    6157#endif
    62     tolua_core_open(luaState_);
     58    tolua_Core_open(luaState_);
    6359    output_ = "";
    6460    isRunning_ = false;
     
    6864  {
    6965    output_ += str;
    70     COUT(4) << "Lua_output!:" << std::endl << str << std::endl << "***" << std::endl;
     66//    COUT(4) << "Lua_output!:" << std::endl << str << std::endl << "***" << std::endl;
     67    COUT(5) << str;
    7168  }
    7269
     
    10198
    10299    if (luaTags) luaSource_ = replaceLuaTags(levelString);
    103     COUT(4) << "ParsedSourceCode: " << luaSource_ << std::endl;
     100    COUT(5) << "ParsedSourceCode: " << luaSource_ << std::endl;
    104101  }
    105102
     
    152149  }
    153150
    154   unsigned int LuaBind::getNextQuote(const std::string& text, unsigned int start)
    155   {
    156     unsigned int quote = start - 1;
    157 
    158     while ((quote = text.find('\"', quote + 1)) != std::string::npos)
    159     {
    160       unsigned int backslash = quote;
    161       unsigned int numbackslashes = 0;
    162       for (; backslash > 0; backslash--, numbackslashes++)
    163         if (text[backslash - 1] != '\\')
    164           break;
    165 
    166       if (numbackslashes % 2 == 0)
    167         break;
    168     }
    169 
    170     return quote;
    171   }
    172 
    173151  std::string LuaBind::replaceLuaTags(const std::string& text)
    174152  {
    175153    // chreate map with all Lua tags
    176     std::map<unsigned int, bool> luaTags;
    177     {
    178       unsigned int pos = 0;
     154    std::map<size_t, bool> luaTags;
     155    {
     156      size_t pos = 0;
    179157      while ((pos = text.find("<?lua", pos)) != std::string::npos)
    180158        luaTags[pos++] = true;
    181159    }
    182160    {
    183       unsigned int pos = 0;
     161      size_t pos = 0;
    184162      while ((pos = text.find("?>", pos)) != std::string::npos)
    185163        luaTags[pos++] = false;
     
    188166    // erase all tags from the map that are between two quotes
    189167    {
    190       std::map<unsigned int, bool>::iterator it = luaTags.begin();
    191       std::map<unsigned int, bool>::iterator it2 = it;
     168      std::map<size_t, bool>::iterator it = luaTags.begin();
     169      std::map<size_t, bool>::iterator it2 = it;
    192170      bool bBetweenQuotes = false;
    193       unsigned int pos = 0;
     171      size_t pos = 0;
    194172      while ((pos = getNextQuote(text, pos)) != std::string::npos)
    195173      {
     
    214192    {
    215193      bool expectedValue = true;
    216       for (std::map<unsigned int, bool>::iterator it = luaTags.begin(); it != luaTags.end(); ++it)
    217       {
    218         if ((*it).second == expectedValue)
     194      for (std::map<size_t, bool>::iterator it = luaTags.begin(); it != luaTags.end(); ++it)
     195      {
     196        if (it->second == expectedValue)
    219197          expectedValue = !expectedValue;
    220198        else
     
    234212    std::string output;
    235213    {
    236       std::map<unsigned int, bool>::iterator it = luaTags.begin();
     214      std::map<size_t, bool>::iterator it = luaTags.begin();
    237215      bool bInPrintFunction = true;
    238       unsigned int start = 0;
    239       unsigned int end = 0;
     216      size_t start = 0;
     217      size_tend = 0;
    240218
    241219      do
     
    253231          std::string temp = text.substr(start, end - start);
    254232          {
    255             unsigned int pos = 0;
     233            size_t pos = 0;
    256234            while ((pos = temp.find('[', pos)) != std::string::npos)
    257235            {
    258236              unsigned int tempCounter = 1;
    259               unsigned int tempPos = pos++;
     237              size_t tempPos = pos++;
    260238              while(temp[++tempPos] == '=') {
    261239                tempCounter++;
     
    272250          }
    273251          {
    274             unsigned int pos = 0;
     252            size_t pos = 0;
    275253            while ((pos = temp.find(']', pos)) != std::string::npos)
    276254            {
    277255              unsigned int tempCounter = 1;
    278               unsigned int tempPos = pos++;
     256              size_t tempPos = pos++;
    279257              while(temp[++tempPos] == '=') {
    280258                tempCounter++;
  • code/branches/objecthierarchy/src/core/LuaBind.h

    • Property svn:eol-style set to native
    r1954 r1959  
    2828
    2929/**
    30  @file  LuaBind.h
     30 @file
    3131 @brief Representation of an interface to lua
    3232 @author Benjamin Knecht <beni_at_orxonox.net>
     
    3939
    4040extern "C" {
    41 #include <lua.h>
     41#include <lua/lua.h>
    4242}
    4343
     
    4747namespace orxonox // tolua_export
    4848{ // tolua_export
    49 
    50   class _CoreExport LuaBind // tolua_export
    51   { // tolua_export
     49  class _CoreExport LuaBind
     50  {
     51  /*
     52  class LuaBind { // tolua_export
     53  */
    5254    struct LoadS {
    5355      const char *s;
     
    7375    inline std::string getLuaOutput() { return output_; };
    7476    //inline std::string* getFileString() { return &fileString_; };
     77    inline void clearLuaOutput() { output_ = ""; }
    7578
    76     unsigned int getNextQuote(const std::string& text, unsigned int start);
    7779    std::string replaceLuaTags(const std::string& text); // tolua_export
    7880
  • code/branches/objecthierarchy/src/core/tolua/tolua.pkg

    r1755 r1959  
    1 $cfile "../../src/core/Script.h"
     1$cfile "../../src/core/LuaBind.h"
    22$cfile "../../src/core/CommandExecutor.h"
  • code/branches/objecthierarchy/src/orxonox/CMakeLists.txt

    r1957 r1959  
    5454  objects/Tickable.cc
    5555  objects/Test.cc
     56  objects/Script.cc
     57  objects/Trigger.cc
     58  objects/DistanceTrigger.cc
    5659
    5760  objects/infos/Info.cc
     
    7477  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
    7578)
    76        
     79
     80
    7781ADD_EXECUTABLE( orxonox ${ORXONOX_SRC_FILES} )
    7882
  • code/branches/objecthierarchy/src/orxonox/objects/DistanceTrigger.cc

    • Property svn:eol-style set to native
  • code/branches/objecthierarchy/src/orxonox/objects/DistanceTrigger.h

    • Property svn:eol-style set to native
  • code/branches/objecthierarchy/src/orxonox/objects/Script.cc

    • Property svn:eol-style set to native
  • code/branches/objecthierarchy/src/orxonox/objects/Script.h

    • Property svn:eol-style set to native
  • code/branches/objecthierarchy/src/orxonox/objects/Trigger.cc

    • Property svn:eol-style set to native
    r1954 r1959  
    223223    XMLPortParamLoadOnly(Trigger, "stayOn", setStayOn, xmlelement, mode);
    224224    XMLPortParamLoadOnly(Trigger, "activations", setActivations, xmlelement, mode);
     225    XMLPortParamLoadOnly(Trigger, "invert", setInvert, xmlelement, mode);
    225226    //XMLPortParamLoadOnlyTemplate(Trigger, "mode", setMode, xmlelement, mode, std::string);
    226227
  • code/branches/objecthierarchy/src/orxonox/objects/Trigger.h

    • Property svn:eol-style set to native
    r1954 r1959  
    5656      inline bool isActive() { return bActive_; }
    5757      void addTrigger(Trigger* trig);
     58      void setInvert(int invert) { bInvertMode_ = invert; }
    5859      const Trigger* getTrigger(unsigned int index) const;
    5960      void setVisibility(bool bVisible);
  • code/branches/objecthierarchy/visual_studio/vc8/base.vsprops

Note: See TracChangeset for help on using the changeset viewer.