Skip to content

Commit

Permalink
Lua: Fix package path using parent autorun path
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Dec 17, 2024
1 parent 517b299 commit c93ee5e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/mods/ScriptRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1220,14 +1220,11 @@ void ScriptRunner::reset_scripts() {
std::filesystem::create_directories(autorun_path);
spdlog::info("[ScriptRunner] Loading scripts...");

auto path = std::filesystem::path(autorun_path);
auto dir = path.parent_path();

std::string old_path = m_main_state->lua()["package"]["path"];

std::string package_path = old_path + ";" + dir.string() + "/?.lua";
package_path = package_path + ";" + dir.string() + "/?/init.lua";
package_path = package_path + ";" + dir.string() + "/?.dll";
std::string package_path = old_path + ";" + autorun_path.string() + "/?.lua";
package_path = package_path + ";" + autorun_path.string() + "/?/init.lua";
package_path = package_path + ";" + autorun_path.string() + "/?.dll";

m_main_state->lua()["package"]["path"] = package_path;

Expand Down

0 comments on commit c93ee5e

Please sign in to comment.