Skip to content

Commit e46e241

Browse files
committed
Set up package.preload.luacom *before* calling the sandbox
1 parent 37547fb commit e46e241

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

scripting/lua_scripting.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -209,22 +209,6 @@ void CScriptEngine::OpenLuaDelayed ()
209209
// unless they explicitly enable it, remove ability to load DLLs
210210
DisableDLLs (L);
211211

212-
m_pDoc->m_iCurrentActionSource = eLuaSandbox;
213-
214-
// preliminary sand-box stuff
215-
ParseLua (App.m_strLuaScript, "Sandbox");
216-
217-
// this is so useful I am adding it in (see check.lua)
218-
ParseLua ( \
219-
"function check (result) \
220-
if result ~= error_code.eOK then\
221-
error (error_desc [result] or \
222-
string.format (\"Unknown error code: %i\", result), 2) end; end",
223-
"Check function");
224-
225-
m_pDoc->m_iCurrentActionSource = eUnknownActionSource;
226-
227-
228212
// add luacom to package.preload
229213
lua_getglobal (L, LUA_LOADLIBNAME); // package table
230214

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

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

230+
// this is so useful I am adding it in (see check.lua)
231+
ParseLua ( \
232+
"function check (result) \
233+
if result ~= error_code.eOK then\
234+
error (error_desc [result] or \
235+
string.format (\"Unknown error code: %i\", result), 2) end; end",
236+
"Check function");
237+
238+
// preliminary sand-box stuff
239+
m_pDoc->m_iCurrentActionSource = eLuaSandbox;
240+
ParseLua (App.m_strLuaScript, "Sandbox");
241+
242+
m_pDoc->m_iCurrentActionSource = eUnknownActionSource;
243+
246244
lua_settop(L, 0); // clear stack
247245

248246
} // end of OpenLuaDelayed

0 commit comments

Comments
 (0)