From edd63080b5d9df2a1e717899cf88bc8b45468186 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sun, 1 Apr 2012 17:00:25 +0400 Subject: [PATCH] Only print the shortcut help once in the lua interactive mode. --- library/LuaTools.cpp | 17 +++++++++++------ library/lua/dfhack.lua | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/library/LuaTools.cpp b/library/LuaTools.cpp index 8b3fa0377..77eda125a 100644 --- a/library/LuaTools.cpp +++ b/library/LuaTools.cpp @@ -225,11 +225,16 @@ bool DFHack::Lua::InterpreterLoop(color_ostream &out, lua_State *state, DFHack::CommandHistory hist; hist.load(hfile); - out.print("Type quit to exit interactive lua interpreter.\n" - "Shortcuts:\n" - " '= foo' => '_1,_2,... = foo'\n" - " '! foo' => 'print(foo)'\n" - "Both assign the first result to '_'\n"); + out.print("Type quit to exit interactive lua interpreter.\n"); + + static bool print_banner = true; + if (print_banner) { + out.print("Shortcuts:\n" + " '= foo' => '_1,_2,... = foo'\n" + " '! foo' => 'print(foo)'\n" + "Both save the first result as '_'.\n"); + print_banner = false; + } Console &con = static_cast(out); @@ -305,7 +310,7 @@ bool DFHack::Lua::InterpreterLoop(color_ostream &out, lua_State *state, { if (!load_with_env(out, state, curline, base)) continue; - if (!SafeCall(out, state, 0, LUA_MULTRET)) + if (!SafeCall(out, state, 0, 0)) continue; } } diff --git a/library/lua/dfhack.lua b/library/lua/dfhack.lua index 285da5f1b..b7052b2ea 100644 --- a/library/lua/dfhack.lua +++ b/library/lua/dfhack.lua @@ -26,6 +26,7 @@ function reload(module) end function printall(table) + if table == nil then return end for k,v in pairs(table) do print(k," = "..tostring(v)) end