diff --git a/plugins/boot.lua b/plugins/boot.lua index 7acf23ca19f..11ee6682bae 100644 --- a/plugins/boot.lua +++ b/plugins/boot.lua @@ -1,11 +1,30 @@ -- license:BSD-3-Clause -- copyright-holders:Miodrag Milanovic require('lfs') -local dir = manager:options().entries.pluginspath:value() -package.path = dir .. "/?.lua;" .. dir .. "/?/init.lua" + +local function env_replace(str) + local pathsep = package.config:sub(1,1) + local function dorep(val) + ret = os.getenv(val) + if ret then + return ret + end + return val + end + + if pathsep == '\\' then + str = str:gsub("%%(%w+)%%", dorep) + else + str = str:gsub("%$(%w+)", dorep) + end + return str +end +local dir = env_replace(manager:options().entries.pluginspath:value()) + +package.path = package.path .. ";" .. dir .. "/?.lua;" .. dir .. "/?/init.lua" local json = require('json') -function readAll(file) +local function readAll(file) local f = io.open(file, "rb") local content = f:read("*all") f:close() diff --git a/src/frontend/mame/mame.cpp b/src/frontend/mame/mame.cpp index 000c20033cd..d72d77bbc3e 100644 --- a/src/frontend/mame/mame.cpp +++ b/src/frontend/mame/mame.cpp @@ -160,7 +160,9 @@ void mame_machine_manager::start_luaengine() osd_file::error filerr = file.open("boot.lua"); if (filerr == osd_file::error::NONE) { - m_lua->load_script(file.fullpath()); + std::string exppath; + osd_subst_env(exppath, std::string(file.fullpath())); + m_lua->load_script(exppath.c_str()); } } } diff --git a/src/frontend/mame/pluginopts.cpp b/src/frontend/mame/pluginopts.cpp index 0dd9ca7bcf9..779ac6ff709 100644 --- a/src/frontend/mame/pluginopts.cpp +++ b/src/frontend/mame/pluginopts.cpp @@ -39,6 +39,7 @@ plugin_options::plugin_options() void plugin_options::parse_json(std::string path) { // first try to open as a directory + osd_subst_env(path, path); osd::directory::ptr directory = osd::directory::open(path); if (directory) {