From ccaf76616d830d284c9002b5ac16ffc0176b10ea Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 5 Nov 2016 04:32:20 +0100 Subject: [PATCH 1/6] Add is_ground_content checker --- checks/is_ground_content.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 checks/is_ground_content.lua diff --git a/checks/is_ground_content.lua b/checks/is_ground_content.lua new file mode 100644 index 0000000..9202dc2 --- /dev/null +++ b/checks/is_ground_content.lua @@ -0,0 +1,21 @@ +-- This checker lists all nodes for which is_ground_content == true. + +--[[ BY DEFAULT, NODES CAN BE DESTROYED BY THE CAVE GENERATOR! +This can be prevented by explicitly setting is_ground_content to false. +It is easy to forget to set is_ground_content=false for the nodes which +would have needed it. + +Recommended values for is_ground_content: +- true (default) for any simple node in the ground or underground, + such as dirt, stone, sand, ores, limestone, orthoclase, etc. Basically + anything else where caves make sense and it doesn't hurt if the cave + generator destroy these nodes. +- false for complex nodes, decorational nodes of “artificial” origin, + interactive nodes, nodes with heavy metadata, “unnatural” nodes, etc. + Examples: Chests, furnaces, fences, ladders, stone bricks, etc.]] + +for name, def in pairs(minetest.registered_nodes) do + if def.is_ground_content then + print(name) + end +end From 982b440738174ef2782687a4bab75cd5e368beec Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 5 Nov 2016 04:32:33 +0100 Subject: [PATCH 2/6] Add light_source >= 15 checker --- checks/light_source_15.lua | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 checks/light_source_15.lua diff --git a/checks/light_source_15.lua b/checks/light_source_15.lua new file mode 100644 index 0000000..68b4c23 --- /dev/null +++ b/checks/light_source_15.lua @@ -0,0 +1,8 @@ +-- List all nodes for which light_source >= 15 +-- light_source 15 is reserved for sunlight. The engine might have issues with this value. + +for name, def in pairs(minetest.registered_nodes) do + if def.light_source >= 15 then + print(name) + end +end From a42d20d5466c2019b5d01023fe61476a008c709e Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 5 Nov 2016 04:32:54 +0100 Subject: [PATCH 3/6] Add checker for listing entities --- checks/list_entities.lua | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 checks/list_entities.lua diff --git a/checks/list_entities.lua b/checks/list_entities.lua new file mode 100644 index 0000000..aefdfe0 --- /dev/null +++ b/checks/list_entities.lua @@ -0,0 +1,7 @@ +-- Lists all the registered entities (except builtin) +for id, def in pairs(minetest.registered_entities) do + -- Ignore builtin entities + if string.sub(id, 1, 9) ~= "__builtin" then + print(id) + end +end From 969320724a3c9ecad121157f098e9364f53217e1 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 5 Nov 2016 04:33:08 +0100 Subject: [PATCH 4/6] Add checker for missing descriptions --- checks/no_item_description.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 checks/no_item_description.lua diff --git a/checks/no_item_description.lua b/checks/no_item_description.lua new file mode 100644 index 0000000..7887aa1 --- /dev/null +++ b/checks/no_item_description.lua @@ -0,0 +1,11 @@ +-- Lists all items without description. +-- Setting the description is optional, but recommended. + +for name, def in pairs(minetest.registered_items) do + -- Hand gets a free pass + if name ~= "" then + if (def.description == "" or def.description == nil) and def.groups.not_in_creative_inventory ~= 1 then + print(name) + end + end +end From 871c9c1272bbe84d33e122d48613b36f41c6d9a0 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 5 Nov 2016 04:33:27 +0100 Subject: [PATCH 5/6] Add checker for items which can (probably) not be obtained --- checks/unobtainable_items.lua | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 checks/unobtainable_items.lua diff --git a/checks/unobtainable_items.lua b/checks/unobtainable_items.lua new file mode 100644 index 0000000..0aa9df1 --- /dev/null +++ b/checks/unobtainable_items.lua @@ -0,0 +1,40 @@ +-- Lists all items which seem to be unobtainable by normal means (not dropped or crafted by anything). +local items = {} +for item, _ in pairs(minetest.registered_items) do + if item ~= "unknown" and item ~= "ignore" and item ~= "air" and item ~= "" then + items[item] = false + end +end + +for item, def in pairs(minetest.registered_items) do + if minetest.get_all_craft_recipes(item) ~= nil then + items[item] = true + end + -- Ignore stuff not in creative inventory + if def.description == nil or def.description == "" or def.groups.not_in_creative_inventory == 1 then + items[item] = true + end + if def.type == "node" then + if def.drop == nil then + items[item] = true + elseif type(def.drop) == "string" and def.drop ~= "" then + local dropstack = ItemStack(def.drop) + if not dropstack:is_empty() then + local dropname = dropstack:get_name() + items[dropname] = true + end + elseif type(def.drop) == "table" then + for i=1,#def.drop.items do + for j=1,#def.drop.items[i].items do + items[def.drop.items[i].items[j]] = true + end + end + end + end +end + +for item, obtainable in pairs(items) do + if obtainable == false then + print(item) + end +end From c297d7f0a05877667ab98e769675f3cfc3a064bb Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 5 Nov 2016 04:33:52 +0100 Subject: [PATCH 6/6] Add checker for (probably) useless items --- checks/useless_items.lua | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 checks/useless_items.lua diff --git a/checks/useless_items.lua b/checks/useless_items.lua new file mode 100644 index 0000000..8d8158e --- /dev/null +++ b/checks/useless_items.lua @@ -0,0 +1,66 @@ +-- Lists all items which are probably useless (not a node, not a weapon, not a mining tool, not used in any crafting recipe). +-- This checker is not perfect and tends to have a couple of false-positives. + +local items_in_craft = {} +for k,v in pairs(minetest.registered_items) do + local recps = minetest.get_all_craft_recipes(k) + if recps ~= nil then + for r=1,#recps do + local recp = recps[r] + if recp ~= nil and recp.items ~= nil then + local table_length + if recp.width == 0 then + table_length = #recp.items + else + table_length = math.pow(recp.width, 2) + end + for i=1, table_length do + if recp.items[i] ~= nil then + items_in_craft[recp.items[i]] = true + end + end + end + end + end +end + +local check = function(name, def) + -- Is it used in ANY crafting recipe? + if items_in_craft[name] == true then + return + end + -- Is it the hand? + if name == "" then + return + end + -- Is it a tool? + if def.tool_capabilities ~= nil then + -- Mining tool? + if def.tool_capabilities.groupcaps ~= nil then + for k, v in pairs(def.tool_capabilities.groupcaps) do + return + end + end + -- Weapon? + if def.tool_capabilities.damage_groups ~= nil then + for k, v in pairs(def.tool_capabilities.damage_groups) do + return + end + end + end + -- Are there any callback functions defined? + -- TODO: Also check on_secondary use, on_place, on_drop + if def.on_use ~= nil or def.after_use ~= nil then + return + end + + -- This item survived all checks, so we print it. It's probably (!) useless. + print(name) +end + +for name, def in pairs(minetest.registered_tools) do + check(name, def) +end +for name, def in pairs(minetest.registered_craftitems) do + check(name, def) +end