Skip to content

Commit

Permalink
Set up package.preload.luacom *before* calling the sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Sep 2, 2010
1 parent 37547fb commit e46e241
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions scripting/lua_scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,22 +209,6 @@ void CScriptEngine::OpenLuaDelayed ()
// unless they explicitly enable it, remove ability to load DLLs
DisableDLLs (L);

m_pDoc->m_iCurrentActionSource = eLuaSandbox;

// preliminary sand-box stuff
ParseLua (App.m_strLuaScript, "Sandbox");

// this is so useful I am adding it in (see check.lua)
ParseLua ( \
"function check (result) \
if result ~= error_code.eOK then\
error (error_desc [result] or \
string.format (\"Unknown error code: %i\", result), 2) end; end",
"Check function");

m_pDoc->m_iCurrentActionSource = eUnknownActionSource;


// add luacom to package.preload
lua_getglobal (L, LUA_LOADLIBNAME); // package table

Expand All @@ -243,6 +227,20 @@ void CScriptEngine::OpenLuaDelayed ()

lua_pop (L, 1); // get rid of package table from stack

// this is so useful I am adding it in (see check.lua)
ParseLua ( \
"function check (result) \
if result ~= error_code.eOK then\
error (error_desc [result] or \
string.format (\"Unknown error code: %i\", result), 2) end; end",
"Check function");

// preliminary sand-box stuff
m_pDoc->m_iCurrentActionSource = eLuaSandbox;
ParseLua (App.m_strLuaScript, "Sandbox");

m_pDoc->m_iCurrentActionSource = eUnknownActionSource;

lua_settop(L, 0); // clear stack

} // end of OpenLuaDelayed
Expand Down

0 comments on commit e46e241

Please sign in to comment.