static inline void loadscript( const filePath& path, void *ud )
{
    CLuaMain *main = (CLuaMain*)ud;
    lua_State *state = main->GetVirtualMachine();

    filePath relPath;
    fileRoot->GetRelativePath( path, true, relPath );

    std::vector <char> buff;
    fileRoot->ReadToBuffer( path, buff );

    // Zero terminate
    buff.push_back( 0 );

    if ( lint_loadscript( state, &buff[0], relPath.c_str() ) )
    {
        std::cout << "init: " << relPath << "\n";
    }
}
///////////////////////////////////////////////////////////////
//
// GetMapEventDebugInfo
//
// Get current Lua source file and line number
//
///////////////////////////////////////////////////////////////
void GetMapEventDebugInfo(CMapEvent* pMapEvent, const char*& szFilename, int& iLineNumber)
{
    CLuaMain* pLuaMain = pMapEvent->GetVM();

    if (!pLuaMain)
        return;

    lua_State* luaVM = pLuaMain->GetVirtualMachine();

    if (!luaVM)
        return;

    const CLuaFunctionRef& iLuaFunction = pMapEvent->GetLuaFunction();
    lua_Debug              debugInfo;
    lua_getref(luaVM, iLuaFunction.ToInt());

    if (lua_getinfo(luaVM, ">lS", &debugInfo))
    {
        // Make sure this function isn't defined in a string
        if (debugInfo.source[0] == '@')
        {
            szFilename = debugInfo.source;
            iLineNumber = debugInfo.currentline != -1 ? debugInfo.currentline : debugInfo.linedefined;
        }
        else
        {
            szFilename = debugInfo.short_src;
        }

        // Remove path
        if (const char* szNext = strrchr(szFilename, '\\'))
            szFilename = szNext + 1;

        if (const char* szNext = strrchr(szFilename, '/'))
            szFilename = szNext + 1;
    }
}