Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 19, 2009, 12:19:11 AM (15 years ago)
Author:
rgrieder
Message:

Cleaned out the lua script files for the GUI.
Also replaced "require" function to support resources.
Fixed a problem with the return value of doFile, includeFile and require being discarded because the tolua binding is for a C++ function returning void.

File:
1 edited

Legend:

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

    r5660 r5661  
    147147            sourceFileInfo_ = sourceFileInfo;
    148148
    149         //if (!bIsRunning_)
    150         //{
    151         //    bIsRunning_ = true;
    152 
    153149        int error = 0;
    154150#if LUA_VERSION_NUM != 501
     
    163159        // execute the chunk
    164160        if (error == 0)
    165             error = lua_pcall(luaState_, 0, 0, 0);
     161            error = lua_pcall(luaState_, 0, 1, 0);
    166162        if (error != 0)
    167163        {
     
    170166                origin = " originating from " + sourceFileInfo_->filename;
    171167            COUT(2) << "Error in Lua-script" << origin << ": " << lua_tostring(luaState_, -1) << std::endl;
    172         }
    173 
    174         //    bIsRunning_ = false;
    175         //}
    176         //else
    177         //{
    178         //    COUT(2) << "Warning: LuaState do function called while running!" << std::endl;
    179         //}
     168            // return value is nil
     169            lua_pushnil(luaState_);
     170        }
     171        // push return value because it will get lost since the return value of this function is void
     172        lua_setglobal(luaState_, "LuaStateReturnValue");
    180173
    181174        // Load the old info again
     
    191184    {
    192185        OutputHandler::getOutStream().setOutputLevel(level) << message << std::endl;
     186    }
     187
     188    bool LuaState::fileExists(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths)
     189    {
     190        shared_ptr<ResourceInfo> info =  this->getFileInfo(filename, resourceGroup, bSearchOtherPaths);
     191        if (info == NULL)
     192            return false;
     193        else
     194            return true;
    193195    }
    194196
Note: See TracChangeset for help on using the changeset viewer.