diff options
author | aunsane <aunsane@gmail.com> | 2018-03-22 01:53:49 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2018-03-22 01:54:09 +0300 |
commit | 2a498d86625f65f6ab308fa20c421099c785bf94 (patch) | |
tree | 9c0d59f41411e46288f88ccdbde4a0d23f440720 /plugins/MirLua/src/mlua_script_loader.cpp | |
parent | 46cded99bbfb90bea8e998e9183c20cc3e4f7365 (diff) |
MirLua: various fixes
- CMLua now inherit PLUGIN
- additional lua fuctions initialization moved to separated loader
- ability to realod script without object recreation
- scropt object should control own enable state
- fix m_json whit is not workes almost at all
- version bump
Diffstat (limited to 'plugins/MirLua/src/mlua_script_loader.cpp')
-rw-r--r-- | plugins/MirLua/src/mlua_script_loader.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/plugins/MirLua/src/mlua_script_loader.cpp b/plugins/MirLua/src/mlua_script_loader.cpp index 60ceb5cbb5..95701b4559 100644 --- a/plugins/MirLua/src/mlua_script_loader.cpp +++ b/plugins/MirLua/src/mlua_script_loader.cpp @@ -1,9 +1,27 @@ #include "stdafx.h"
-CMLuaScriptLoader::CMLuaScriptLoader(lua_State *L) : L(L)
+CMLuaScriptLoader::CMLuaScriptLoader(lua_State *L)
+ : L(L)
{
}
+void CMLuaScriptLoader::SetPaths()
+{
+ wchar_t path[MAX_PATH];
+
+ lua_getglobal(L, LUA_LOADLIBNAME);
+
+ FoldersGetCustomPathT(g_hCLibsFolder, path, _countof(path), VARSW(MIRLUA_PATHT));
+ lua_pushfstring(L, "%s\\?.dll", T2Utf(path));
+ lua_setfield(L, -2, "cpath");
+
+ FoldersGetCustomPathT(g_hScriptsFolder, path, _countof(path), VARSW(MIRLUA_PATHT));
+ lua_pushfstring(L, "%s\\?.lua", T2Utf(path));
+ lua_setfield(L, -2, "path");
+
+ lua_pop(L, 1);
+}
+
void CMLuaScriptLoader::LoadScript(const wchar_t *scriptDir, const wchar_t *file)
{
wchar_t fullPath[MAX_PATH], path[MAX_PATH];
@@ -13,7 +31,7 @@ void CMLuaScriptLoader::LoadScript(const wchar_t *scriptDir, const wchar_t *file CMLuaScript *script = new CMLuaScript(L, path);
g_mLua->Scripts.insert(script);
- if (db_get_b(NULL, MODULE, _T2A(file), 1) == FALSE) {
+ if (!script->IsEnabled()) {
Log(L"%s:PASS", path);
return;
}
@@ -24,6 +42,8 @@ void CMLuaScriptLoader::LoadScript(const wchar_t *scriptDir, const wchar_t *file void CMLuaScriptLoader::LoadScripts()
{
+ SetPaths();
+
wchar_t scriptDir[MAX_PATH];
FoldersGetCustomPathT(g_hScriptsFolder, scriptDir, _countof(scriptDir), VARSW(MIRLUA_PATHT));
|