Add ability and option to automatically categorise items
This commit is contained in:
parent
7e36afbb83
commit
5266d785d7
|
@ -24,6 +24,69 @@ unified_inventory.register_category('lighting', {
|
||||||
label = "Lighting"
|
label = "Lighting"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
if unified_inventory.automatic_categorization then
|
||||||
|
minetest.register_on_mods_loaded(function()
|
||||||
|
|
||||||
|
-- Add biome nodes to environment category
|
||||||
|
for _,def in pairs(minetest.registered_biomes) do
|
||||||
|
local env_nodes = {
|
||||||
|
def.node_riverbed, def.node_top, def.node_filler, def.node_dust,
|
||||||
|
}
|
||||||
|
for i,node in pairs(env_nodes) do
|
||||||
|
if node then
|
||||||
|
unified_inventory.add_category_item('environment', node)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add minable ores to minerals and everything else (pockets of stone & sand variations) to environment
|
||||||
|
for _,item in pairs(minetest.registered_ores) do
|
||||||
|
if item.ore_type == "scatter" then
|
||||||
|
local drop = minetest.registered_nodes[item.ore].drop
|
||||||
|
if drop and drop ~= "" then
|
||||||
|
unified_inventory.add_category_item('minerals', item.ore)
|
||||||
|
unified_inventory.add_category_item('minerals', drop)
|
||||||
|
else
|
||||||
|
unified_inventory.add_category_item('environment', item.ore)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
unified_inventory.add_category_item('environment', item.ore)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add items by item definition
|
||||||
|
for name, def in pairs(minetest.registered_items) do
|
||||||
|
local group = def.groups or {}
|
||||||
|
if not group.not_in_creative_inventory then
|
||||||
|
if group.stair or
|
||||||
|
group.slab or
|
||||||
|
group.wall or
|
||||||
|
group.fence then
|
||||||
|
unified_inventory.add_category_item('building', name)
|
||||||
|
elseif group.flora or
|
||||||
|
group.flower or
|
||||||
|
group.seed or
|
||||||
|
group.leaves or
|
||||||
|
group.sapling or
|
||||||
|
group.tree then
|
||||||
|
unified_inventory.add_category_item('plants', name)
|
||||||
|
elseif def.type == 'tool' then
|
||||||
|
unified_inventory.add_category_item('tools', name)
|
||||||
|
elseif def.liquidtype == 'source' then
|
||||||
|
unified_inventory.add_category_item('environment', name)
|
||||||
|
elseif def.light_source and def.light_source > 0 then
|
||||||
|
unified_inventory.add_category_item('lighting', name)
|
||||||
|
elseif doors and doors.registered_doors and doors.registered_doors[name..'_a'] or
|
||||||
|
doors and doors.registered_trapdoors and doors.registered_trapdoors[name] then
|
||||||
|
unified_inventory.add_category_item('building', name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- [[
|
||||||
unified_inventory.add_category_items('plants', {
|
unified_inventory.add_category_items('plants', {
|
||||||
"default:dry_grass_5",
|
"default:dry_grass_5",
|
||||||
"default:acacia_sapling",
|
"default:acacia_sapling",
|
||||||
|
@ -504,6 +567,8 @@ unified_inventory.add_category_items('lighting', {
|
||||||
"default:mese_post_light_pine_wood",
|
"default:mese_post_light_pine_wood",
|
||||||
"default:mese_post_light_aspen_wood"
|
"default:mese_post_light_aspen_wood"
|
||||||
})
|
})
|
||||||
|
--]]
|
||||||
|
|
||||||
|
|
||||||
--[[ UNCATEGORISED
|
--[[ UNCATEGORISED
|
||||||
|
|
||||||
|
@ -616,17 +681,20 @@ unified_inventory.add_category_items('lighting', {
|
||||||
"unified_inventory:bag_large",
|
"unified_inventory:bag_large",
|
||||||
"unified_inventory:bag_medium",
|
"unified_inventory:bag_medium",
|
||||||
"unified_inventory:bag_small",
|
"unified_inventory:bag_small",
|
||||||
]]
|
--]]
|
||||||
|
|
||||||
--[[ LIST UNCATEGORIZED AFTER LOAD
|
--[[ LIST UNCATEGORIZED AFTER LOAD
|
||||||
minetest.after(5, function ( )
|
minetest.register_on_mods_loaded(function()
|
||||||
local l = {}
|
minetest.after(1, function ( )
|
||||||
for name,_ in pairs(minetest.registered_items) do
|
local l = {}
|
||||||
if not unified_inventory.find_category(name) then
|
for name,_ in pairs(minetest.registered_items) do
|
||||||
table.insert(l, name)
|
if not unified_inventory.find_category(name) then
|
||||||
|
-- minetest.log("error", minetest.serialize(minetest.registered_items[name]))
|
||||||
|
table.insert(l, name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
table.sort(l)
|
||||||
table.sort(l)
|
minetest.log(table.concat(l, '",'.."\n"..'"'))
|
||||||
minetest.log(table.concat(l, '",'.."\n"..'"'))
|
end)
|
||||||
end)
|
end)
|
||||||
]]
|
--]]
|
3
init.lua
3
init.lua
|
@ -35,6 +35,9 @@ unified_inventory = {
|
||||||
-- "Lite" mode
|
-- "Lite" mode
|
||||||
lite_mode = minetest.settings:get_bool("unified_inventory_lite"),
|
lite_mode = minetest.settings:get_bool("unified_inventory_lite"),
|
||||||
|
|
||||||
|
-- Items automatically added to categories based on item definitions
|
||||||
|
automatic_categorization = (minetest.settings:get_bool("unified_inventory_automatic_categorization") ~= false),
|
||||||
|
|
||||||
-- Trash enabled
|
-- Trash enabled
|
||||||
trash_enabled = (minetest.settings:get_bool("unified_inventory_trash") ~= false),
|
trash_enabled = (minetest.settings:get_bool("unified_inventory_trash") ~= false),
|
||||||
imgscale = 1.25,
|
imgscale = 1.25,
|
||||||
|
|
|
@ -9,3 +9,6 @@ unified_inventory_bags (Enable bags) bool true
|
||||||
#If enabled, the trash slot can be used by those without both creative
|
#If enabled, the trash slot can be used by those without both creative
|
||||||
#and the give privilege.
|
#and the give privilege.
|
||||||
unified_inventory_trash (Enable trash) bool true
|
unified_inventory_trash (Enable trash) bool true
|
||||||
|
|
||||||
|
|
||||||
|
unified_inventory_automatic_categorization (Items automatically added to categories) bool true
|
Loading…
Reference in New Issue