From 1d8998de22fe419f12dacff28154d1c3d598b84b Mon Sep 17 00:00:00 2001 From: Timur Kelman Date: Sun, 23 Feb 2020 16:57:57 +0100 Subject: [PATCH] allow custom filter in `dfhack.printall_recurse` Objects with links like `job` output way too much. With this change, it's possible to provide an optional filter and exclude the `list_link`. ``` [lua]# j = dfhack.gui.getSelectedJob() [lua]# printall_recurse(j, {[tostring(j.list_link)]=true, [tostring(j.pos)]=true}) ``` --- library/lua/dfhack.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/lua/dfhack.lua b/library/lua/dfhack.lua index 049297385..73fd651e2 100644 --- a/library/lua/dfhack.lua +++ b/library/lua/dfhack.lua @@ -285,8 +285,8 @@ do_print_recurse = function(printfn, value, seen, indent) return recurse_type_map[t](printfn, value, seen, indent) end -function printall_recurse(value) - local seen = {} +function printall_recurse(value, seen) + local seen = seen or {} do_print_recurse(dfhack.println, value, seen, 0) end