Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 23, 2010, 11:46:11 AM (15 years ago)
Author:
rgrieder
Message:

Activated Strict.lua
That means you can no longer assign to or access an undeclared global variable on function scope.
Declaring: either assign anything to the variable (including nil) on file scope
or use the function global("myVar", "myVar2", …, "myVarN") (mind the strings!)

Location:
code/branches/gamestates3/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gamestates3/src/libraries/core/LuaState.cc

    r6763 r6774  
    5353    DeclareToluaInterface(Core);
    5454
    55     LuaState::LuaState()
     55    LuaState::LuaState(bool bStrict)
    5656        : bIsRunning_(false)
    5757        , includeParseFunction_(NULL)
     
    8282        tolua_pushusertype(luaState_, static_cast<void*>(this), "orxonox::LuaState");
    8383        lua_setglobal(luaState_, "luaState");
     84
     85        // Strict.lua ensures that global variables are not declared inside a function scope
     86        if (bStrict)
     87        {
     88            if (!this->doFile("Strict.lua"))
     89                ThrowException(InitialisationFailed, "Running Strict.lua failed");
     90        }
     91        else
     92        {
     93            // Add dummy function for declaring global variables
     94            this->doString("global = function(...) end");
     95        }
    8496
    8597        // Parse init script
  • code/branches/gamestates3/src/libraries/core/LuaState.h

    r6763 r6774  
    6868    { // tolua_export
    6969    public:
    70         LuaState();
     70        LuaState(bool bStrict = true);
    7171        ~LuaState();
    7272
  • code/branches/gamestates3/src/orxonox/items/MultiStateEngine.cc

    r6709 r6774  
    6161            this->defEngineSndNormal_->setLooping(true);
    6262            this->defEngineSndBoost_->setLooping(true);
    63             this->lua_ = new LuaState();
     63            this->lua_ = new LuaState(false);
    6464        }
    6565        else
Note: See TracChangeset for help on using the changeset viewer.