|
|
@ -562,7 +562,6 @@ function Script:get_flags()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
internal.scripts = internal.scripts or {}
|
|
|
|
internal.scripts = internal.scripts or {}
|
|
|
|
local scripts = internal.scripts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local hack_path = dfhack.getHackPath()
|
|
|
|
local hack_path = dfhack.getHackPath()
|
|
|
|
|
|
|
|
|
|
|
@ -583,6 +582,7 @@ local valid_script_flags = {
|
|
|
|
module_strict = {required = false},
|
|
|
|
module_strict = {required = false},
|
|
|
|
alias = {required = false},
|
|
|
|
alias = {required = false},
|
|
|
|
alias_count = {required = false},
|
|
|
|
alias_count = {required = false},
|
|
|
|
|
|
|
|
scripts = {required = false},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function dfhack.run_script(name,...)
|
|
|
|
function dfhack.run_script(name,...)
|
|
|
@ -602,13 +602,18 @@ function dfhack.reqscript(name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
reqscript = dfhack.reqscript
|
|
|
|
reqscript = dfhack.reqscript
|
|
|
|
|
|
|
|
|
|
|
|
function dfhack.script_environment(name, strict)
|
|
|
|
function dfhack.script_environment(name, strict, envVars, scripts)
|
|
|
|
|
|
|
|
scripts = scripts or internal.scripts
|
|
|
|
local path = dfhack.findScript(name)
|
|
|
|
local path = dfhack.findScript(name)
|
|
|
|
if not scripts[path] or scripts[path]:needs_update() then
|
|
|
|
if not scripts[path] or scripts[path]:needs_update() then
|
|
|
|
local _, env = dfhack.run_script_with_env(nil, name, {
|
|
|
|
local _, env = dfhack.run_script_with_env(
|
|
|
|
module=true,
|
|
|
|
envVars,
|
|
|
|
module_strict=(strict and true or false) -- ensure that this key is present if 'strict' is nil
|
|
|
|
name,
|
|
|
|
})
|
|
|
|
{
|
|
|
|
|
|
|
|
scripts=scripts,
|
|
|
|
|
|
|
|
module=true,
|
|
|
|
|
|
|
|
module_strict=(strict and true or false) -- ensure that this key is present if 'strict' is nil
|
|
|
|
|
|
|
|
})
|
|
|
|
return env
|
|
|
|
return env
|
|
|
|
else
|
|
|
|
else
|
|
|
|
if strict and not scripts[path]:get_flags().module then
|
|
|
|
if strict and not scripts[path]:get_flags().module then
|
|
|
@ -625,6 +630,7 @@ function dfhack.run_script_with_env(envVars, name, flags, ...)
|
|
|
|
error('Could not find script ' .. name)
|
|
|
|
error('Could not find script ' .. name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local scripts = flags.scripts or internal.scripts
|
|
|
|
if scripts[file] == nil then
|
|
|
|
if scripts[file] == nil then
|
|
|
|
scripts[file] = Script(file)
|
|
|
|
scripts[file] = Script(file)
|
|
|
|
end
|
|
|
|
end
|
|
|
|