Allow lua scripts to redirect to other lua scripts

Addresses #634, #638
develop
lethosor 2015-06-14 11:56:14 -04:00
parent 4c3ae91e98
commit 862389d217
1 changed files with 9 additions and 0 deletions

@ -451,6 +451,8 @@ local valid_script_flags = {
error = 'Cannot be used as a module' error = 'Cannot be used as a module'
}, },
module_strict = {required = false}, module_strict = {required = false},
alias = {required = false},
alias_count = {required = false},
} }
function dfhack.run_script(name,...) function dfhack.run_script(name,...)
@ -497,6 +499,13 @@ function dfhack.run_script_with_env(envVars, name, flags, ...)
scripts[file] = Script(file) scripts[file] = Script(file)
end end
local script_flags = scripts[file]:get_flags() local script_flags = scripts[file]:get_flags()
if script_flags.alias then
flags.alias_count = (flags.alias_count or 0) + 1
if flags.alias_count > 10 then
error('Too many script aliases: ' .. flags.alias_count)
end
return dfhack.run_script_with_env(envVars, script_flags.alias, flags, ...)
end
for flag, value in pairs(flags) do for flag, value in pairs(flags) do
if value then if value then
local v = valid_script_flags[flag] local v = valid_script_flags[flag]