|
|
|
@ -444,21 +444,18 @@ function dfhack.run_script_with_env(envVars,name,...)
|
|
|
|
|
local perr
|
|
|
|
|
local time = dfhack.filesystem.mtime(file)
|
|
|
|
|
if time == scriptMtime[file] then
|
|
|
|
|
f = scripts[file].runScript
|
|
|
|
|
f = scripts[file].__runScript__
|
|
|
|
|
else
|
|
|
|
|
env = {}
|
|
|
|
|
setmetatable(env, { __index = base_env })
|
|
|
|
|
for x,y in pairs(envVars or {}) do
|
|
|
|
|
env[x] = y
|
|
|
|
|
end
|
|
|
|
|
--reload
|
|
|
|
|
f, perr = loadfile(file, 't', env)
|
|
|
|
|
if not f then
|
|
|
|
|
error(perr)
|
|
|
|
|
end
|
|
|
|
|
-- avoid updating mtime if the script failed to load
|
|
|
|
|
scriptMtime[file] = time
|
|
|
|
|
end
|
|
|
|
|
scripts[file] = env
|
|
|
|
|
env.runScript = f
|
|
|
|
|
env.__runScript__ = f
|
|
|
|
|
return f(...), env
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|