Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6629


Ignore:
Timestamp:
Mar 28, 2010, 10:46:07 PM (14 years ago)
Author:
rgrieder
Message:

Fixed LuaState::doFile return value issue.

Location:
code/branches/gamestate
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gamestate/data/lua/LuaStateInit.lua

    r6628 r6629  
    3434-- Furthermore the ".lua" extension is appended to the moduleName parameter when looking for the file
    3535original_require = require
     36_REQUIREDNAME = ""
     37LuaStateReturnValue = true
    3638require = function(moduleName)
    3739  if not luaState:fileExists(moduleName .. ".lua") then
     
    4446  if not _LOADED[moduleName] then
    4547    -- save old value
    46     _REQUIREDNAME_OLD = _REQUIREDNAME
     48    local _REQUIREDNAME_OLD = _REQUIREDNAME
    4749    _REQUIREDNAME = moduleName
    4850    luaState:doFile(moduleName .. ".lua")
    49     _LOADED[moduleName] = LuaStateReturnValue or true
     51    _LOADED[moduleName] = LuaStateReturnValue
    5052    -- restore old value
    5153    _REQUIREDNAME = _REQUIREDNAME_OLD
  • code/branches/gamestate/src/libraries/core/LuaState.cc

    r6627 r6629  
    170170                origin = " originating from " + sourceFileInfo_->filename;
    171171            COUT(1) << "Error in Lua-script" << origin << ": " << lua_tostring(luaState_, -1) << std::endl;
    172             // return value is nil
    173             lua_pushnil(luaState_);
    174         }
    175         // push return value because it will get lost since the return value of this function is void
     172            // return value is true (not nil!)
     173            lua_pushboolean(luaState_, 1);
     174        }
     175        if (lua_isnil(luaState_, -1))
     176        {
     177            // Nil return values cause problems
     178            lua_pop(luaState_, 1);
     179            lua_pushboolean(luaState_, 1);
     180        }
     181        // Push return value because it will get lost since the return value of this function is void
    176182        lua_setglobal(luaState_, "LuaStateReturnValue");
    177183
Note: See TracChangeset for help on using the changeset viewer.