Add dfhack.run_command (Lua)

Simplified version of runCommand
develop
lethosor 2014-06-07 20:31:14 -04:00
parent 2242d42c9c
commit 91a93a00d2
1 changed files with 12 additions and 1 deletions

@ -256,7 +256,8 @@ function dfhack.interpreter(prompt,hfile,env)
print("Shortcuts:\n"..
" '= foo' => '_1,_2,... = foo'\n"..
" '! foo' => 'print(foo)'\n"..
"Both save the first result as '_'.")
" '~ foo' => 'printall(foo)'\n"..
"All of these save the first result as '_'.")
print_banner = false
end
@ -357,6 +358,16 @@ function dfhack.run_script(name,...)
return f(...)
end
function dfhack.run_command(command, ...)
command = command .. ' ' .. table.concat({...}, ' ')
fragments = internal.runCommand(command)
output = ""
for i, f in pairs(fragments) do
output = output .. f[2]
end
return output
end
-- Per-save init file
function dfhack.getSavePath()