Only print the shortcut help once in the lua interactive mode.

develop
Alexander Gavrilov 2012-04-01 17:00:25 +04:00
parent afe4eba957
commit edd63080b5
2 changed files with 12 additions and 6 deletions

@ -225,11 +225,16 @@ bool DFHack::Lua::InterpreterLoop(color_ostream &out, lua_State *state,
DFHack::CommandHistory hist; DFHack::CommandHistory hist;
hist.load(hfile); hist.load(hfile);
out.print("Type quit to exit interactive lua interpreter.\n" out.print("Type quit to exit interactive lua interpreter.\n");
"Shortcuts:\n"
static bool print_banner = true;
if (print_banner) {
out.print("Shortcuts:\n"
" '= foo' => '_1,_2,... = foo'\n" " '= foo' => '_1,_2,... = foo'\n"
" '! foo' => 'print(foo)'\n" " '! foo' => 'print(foo)'\n"
"Both assign the first result to '_'\n"); "Both save the first result as '_'.\n");
print_banner = false;
}
Console &con = static_cast<Console&>(out); Console &con = static_cast<Console&>(out);
@ -305,7 +310,7 @@ bool DFHack::Lua::InterpreterLoop(color_ostream &out, lua_State *state,
{ {
if (!load_with_env(out, state, curline, base)) if (!load_with_env(out, state, curline, base))
continue; continue;
if (!SafeCall(out, state, 0, LUA_MULTRET)) if (!SafeCall(out, state, 0, 0))
continue; continue;
} }
} }

@ -26,6 +26,7 @@ function reload(module)
end end
function printall(table) function printall(table)
if table == nil then return end
for k,v in pairs(table) do for k,v in pairs(table) do
print(k," = "..tostring(v)) print(k," = "..tostring(v))
end end