-- Macro configuration: key_to_find = "prefer_spots_on_side_with_leader" max_examples_to_find = 5 -- Each rgd is passed into this function: function each_file(rgd) current_file_name = rgd.path -- save the filename of the RGD for later -- Iterate over all root tables in the RGD (eg. GameData) for key,val in rgd do search_table(val,key,"Inherit",key) end end -- Each table in each RGD is passed into this function: -- 'table' => the table being searched -- 'prefix' => the identifier of the table (eg. "GameData["some_ext"]["modifiers"]") -- 'func' => either "Reference" or "Inherit" -- 'tname' => the name of the table (eg. "modifiers") function search_table(table, prefix, func, tname) if tname == key_to_find then -- If the table itself matches the search key: found_one() print(prefix," = ",func,"([[",table["$REF"] or "","]])") end for key,val in table do -- Look through all entries in the table: if type(val) == "userdata" then -- Recursively search child tables: search_table(val,prefix .. "[\"" .. key .. "\"]","Reference",key) elseif key == key_to_find then found_one() if type(v) ~= "string" then print(prefix,"[\"",k,"\"] = ",v) else print(prefix,"[\"",k,"\"] = [[",v,"]]") end end end end -- Whenever an example is found, this function is called function found_one() print("-- Found in file ",current_file_name," :") if (max_examples_to_find or 0) > 0 then max_examples_to_find = max_examples_to_find - 1 if max_examples_to_find < 1 then each_file = nil end end end