summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/mlua.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-06-09 06:44:57 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-06-09 06:44:57 +0000
commitd93bdfc096f018d3b9c80dad756e5b573e886f68 (patch)
treee5561831fa8f318e61d2ffc62d7f718e82674451 /plugins/MirLua/src/mlua.cpp
parent00c46f24d60c9de29293bef608f34114392822d2 (diff)
MirLua:
- added loading of internal modules - added loading of lua scripts - added folders plugin support git-svn-id: http://svn.miranda-ng.org/main/trunk@14069 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/mlua.cpp')
-rw-r--r--plugins/MirLua/src/mlua.cpp36
1 files changed, 22 insertions, 14 deletions
diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp
index ee6d91e117..04200e3777 100644
--- a/plugins/MirLua/src/mlua.cpp
+++ b/plugins/MirLua/src/mlua.cpp
@@ -1,20 +1,28 @@
-#include "stdafx.h"
-
+#include "stdafx.h"
+
CMLua::CMLua()
{
- lua = luaL_newstate();
+ L = luaL_newstate();
+ luaL_openlibs(L);
+
+ luaL_newlib(L, CMLua::coreFunctions);
+ lua_setglobal(L, "M");
+}
+
+CMLua::~CMLua()
+{
+ lua_close(L);
+}
- luaL_openlibs(lua);
- luaL_newlib(lua, CMLua::CoreFunctions);
- lua_setglobal(lua, "M");
+void CMLua::Load(const char *path)
+{
+ luaL_dofile(L, path);
}
-CMLua::~CMLua()
-{
- lua_close(lua);
-}
-
-void CMLua::Load(const char *name)
-{
- luaL_dofile(lua, name);
+void CMLua::Preload(const char *name, lua_CFunction loader)
+{
+ luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
+ lua_pushcfunction(L, loader);
+ lua_setfield(L, -2, name);
+ lua_pop(L, 1);
} \ No newline at end of file