Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 28, 2010, 3:21:44 PM (15 years ago)
Author:
rgrieder
Message:

Lua debugger working perfectly by supplying the fully qualified filename to the lua_load function.
Usage: write pause(message) to any line in your lua code and a self explaining command line debugger will open in the console.
Important note: Turn off the IOConsole (—noIOConsole) or the lua debugger will not work!!!

Location:
code/branches/gamestate/src/libraries/core
Files:
3 edited

Legend:

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

    r6417 r6625  
    134134            sourceFileInfo_ = sourceFileInfo;
    135135
     136        std::string chunkname;
     137        if (sourceFileInfo != NULL && !sourceFileInfo->fileSystemPath.empty())
     138        {
     139            // Provide lua_load with the filename for debug purposes
     140            // The '@' is a Lua convention to identify the chunk name as filename
     141            chunkname = '@' + sourceFileInfo->fileSystemPath;
     142        }
     143        else
     144        {
     145            // Use the beginning of the code string to identify the chunk
     146            chunkname = code.substr(0, 80);
     147        }
     148
    136149        int error = 0;
    137150#if LUA_VERSION_NUM != 501
     
    139152        ls.s = code.c_str();
    140153        ls.size = code.size();
    141         error = lua_load(luaState_, &orxonox::LuaState::lua_Chunkreader, &ls, code.c_str());
     154        error = lua_load(luaState_, &orxonox::LuaState::lua_Chunkreader, &ls, chunkname.c_str());
    142155#else
    143         error = luaL_loadstring(luaState_, code.c_str());
     156        error = luaL_loadbuffer(luaState_, code.c_str(), code.size(), chunkname.c_str());
    144157#endif
    145158
  • code/branches/gamestate/src/libraries/core/Resource.cc

    r6417 r6625  
    2929#include "Resource.h"
    3030
     31#include <boost/filesystem/path.hpp>
    3132#include <OgreException.h>
     33#include <OgreFileSystem.h>
    3234#include <OgreResourceGroupManager.h>
    3335
     
    8991                ptr->group = group;
    9092                ptr->size = it->uncompressedSize;
     93                if (dynamic_cast<Ogre::FileSystemArchive*>(it->archive) != NULL)
     94                {
     95                    boost::filesystem::path base(it->archive->getName());
     96                    base /= it->filename;
     97                    ptr->fileSystemPath = base.string();
     98                }
    9199                return ptr;
    92100            }
  • code/branches/gamestate/src/libraries/core/Resource.h

    r6417 r6625  
    5757        //! Uncompressed size
    5858        size_t size;
     59        //! Absolute file path ("" for files not on filesystem)
     60        std::string fileSystemPath;
    5961    };
    6062
Note: See TracChangeset for help on using the changeset viewer.