forked from teamnwah/openmw-tes3coop
[Server] Add getModFolder() script function and Config environment
This commit is contained in:
parent
b5ce3cebbc
commit
3284769fef
2 changed files with 8 additions and 0 deletions
|
@ -75,6 +75,9 @@ LuaState::LuaState()
|
|||
coreTable["PROTOCOL"] = TES3MP_PROTO_VERSION;
|
||||
coreTable["loadedMods"] = coreTable.create();
|
||||
|
||||
configEnv = sol::environment(*lua, sol::create, lua->globals());
|
||||
lua->set("Config", configEnv); // plain global environment for mod configuration
|
||||
|
||||
// errors in sol::functions catches only in debug build for better performance
|
||||
#ifdef SOL_SAFE_FUNCTIONS
|
||||
lua->set_function("ErrorHandler", [](sol::object error_msg) {
|
||||
|
@ -236,6 +239,10 @@ sol::environment LuaState::openScript(std::string homePath, std::string modname)
|
|||
return homePath + "/data/" + modname + '/';
|
||||
});
|
||||
|
||||
lua->set_function("getModFolder", [homePath, modname]() -> const string{
|
||||
return homePath + "/mods/" + modname + '/';
|
||||
});
|
||||
|
||||
lua->script_file(homePath + "/mods/" + modname + "/main.lua", env);
|
||||
|
||||
sol::table modinfo = env["ModInfo"];
|
||||
|
|
|
@ -40,6 +40,7 @@ private:
|
|||
private:
|
||||
std::shared_ptr<sol::state> lua;
|
||||
sol::environment dataEnv;
|
||||
sol::environment configEnv;
|
||||
std::unique_ptr<CommandController> cmdCtrl;
|
||||
std::unique_ptr<EventController> eventCtrl;
|
||||
std::unique_ptr<TimerController> timerCtrl;
|
||||
|
|
Loading…
Reference in a new issue