This commit is contained in:
Alexander Weber 2016-11-05 10:25:23 +01:00
commit 541b51748d
6 changed files with 153 additions and 0 deletions

View File

@ -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

View File

@ -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

7
checks/list_entities.lua Normal file
View File

@ -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

View File

@ -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

View File

@ -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

66
checks/useless_items.lua Normal file
View File

@ -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