From 5be8311b0de097d62a3d596920723c7a451e9937 Mon Sep 17 00:00:00 2001 From: Isidor Zeuner Date: Wed, 10 Jan 2018 13:11:22 +0100 Subject: [PATCH] selective disabling of stairsplus groups in inventory --- config.lua | 6 ++++++ stairsplus/init.lua | 5 ++++- stairsplus/microblocks.lua | 2 +- stairsplus/panels.lua | 2 +- stairsplus/slabs.lua | 2 +- stairsplus/slopes.lua | 2 +- stairsplus/stairs.lua | 2 +- 7 files changed, 15 insertions(+), 6 deletions(-) diff --git a/config.lua b/config.lua index 8d49c3b..e197084 100644 --- a/config.lua +++ b/config.lua @@ -27,3 +27,9 @@ end -- Show stairs/slabs/panels/microblocks in creative inventory (true or false): setting("bool", "stairsplus_in_creative_inventory", false) + +setting("bool", "stairsplus_microblocks_not_in_creative_inventory", false) +setting("bool", "stairsplus_panels_not_in_creative_inventory", false) +setting("bool", "stairsplus_slabs_not_in_creative_inventory", false) +setting("bool", "stairsplus_slopes_not_in_creative_inventory", false) +setting("bool", "stairsplus_stairs_not_in_creative_inventory", false) diff --git a/stairsplus/init.lua b/stairsplus/init.lua index 5cd415c..79b10f2 100644 --- a/stairsplus/init.lua +++ b/stairsplus/init.lua @@ -34,7 +34,7 @@ function stairsplus.copytable(orig) return copy end -function stairsplus:prepare_groups(groups) +function stairsplus:prepare_groups(groups, disabled_in_inventory) local result = {} if groups then for k, v in pairs(groups) do @@ -46,6 +46,9 @@ function stairsplus:prepare_groups(groups) if not moreblocks.config.stairsplus_in_creative_inventory then result.not_in_creative_inventory = 1 end + if disabled_in_inventory then + result.not_in_creative_inventory = 1 + end return result end diff --git a/stairsplus/microblocks.lua b/stairsplus/microblocks.lua index 50d8487..99c6a46 100644 --- a/stairsplus/microblocks.lua +++ b/stairsplus/microblocks.lua @@ -94,7 +94,7 @@ function stairsplus:register_micro(modname, subname, recipeitem, fields) def.paramtype = "light" def.paramtype2 = def.paramtype2 or "facedir" def.on_place = minetest.rotate_node - def.groups = stairsplus:prepare_groups(fields.groups) + def.groups = stairsplus:prepare_groups(fields.groups, moreblocks.config.stairsplus_microblocks_not_in_creative_inventory) def.description = desc if fields.drop and not (type(fields.drop) == "table") then def.drop = modname.. ":micro_" ..fields.drop..alternate diff --git a/stairsplus/panels.lua b/stairsplus/panels.lua index 98e77fd..8b7384a 100644 --- a/stairsplus/panels.lua +++ b/stairsplus/panels.lua @@ -95,7 +95,7 @@ function stairsplus:register_panel(modname, subname, recipeitem, fields) def.paramtype2 = def.paramtype2 or "facedir" def.on_place = minetest.rotate_node def.description = desc - def.groups = stairsplus:prepare_groups(fields.groups) + def.groups = stairsplus:prepare_groups(fields.groups, moreblocks.config.stairsplus_panels_not_in_creative_inventory) if fields.drop and not (type(fields.drop) == "table") then def.drop = modname.. ":panel_" ..fields.drop..alternate end diff --git a/stairsplus/slabs.lua b/stairsplus/slabs.lua index de7f031..6abe868 100644 --- a/stairsplus/slabs.lua +++ b/stairsplus/slabs.lua @@ -90,7 +90,7 @@ function stairsplus:register_slab(modname, subname, recipeitem, fields) def.paramtype = "light" def.paramtype2 = def.paramtype2 or "facedir" def.on_place = minetest.rotate_node - def.groups = stairsplus:prepare_groups(fields.groups) + def.groups = stairsplus:prepare_groups(fields.groups, moreblocks.config.stairsplus_slabs_not_in_creative_inventory) if alternate == "" then def.groups.slab = 1 end diff --git a/stairsplus/slopes.lua b/stairsplus/slopes.lua index 7d18b3d..a9f9553 100644 --- a/stairsplus/slopes.lua +++ b/stairsplus/slopes.lua @@ -249,7 +249,7 @@ function stairsplus:register_slope(modname, subname, recipeitem, fields) def.paramtype2 = def.paramtype2 or "facedir" def.on_place = minetest.rotate_node def.description = desc - def.groups = stairsplus:prepare_groups(fields.groups) + def.groups = stairsplus:prepare_groups(fields.groups, moreblocks.config.stairsplus_slopes_not_in_creative_inventory) if fields.drop and not (type(fields.drop) == "table") then def.drop = modname.. ":slope_" ..fields.drop..alternate end diff --git a/stairsplus/stairs.lua b/stairsplus/stairs.lua index 815f7ac..d90cfad 100644 --- a/stairsplus/stairs.lua +++ b/stairsplus/stairs.lua @@ -135,7 +135,7 @@ function stairsplus:register_stair(modname, subname, recipeitem, fields) def.paramtype2 = def.paramtype2 or "facedir" def.on_place = minetest.rotate_node def.description = desc - def.groups = stairsplus:prepare_groups(fields.groups) + def.groups = stairsplus:prepare_groups(fields.groups, moreblocks.config.stairsplus_stairs_not_in_creative_inventory) if alternate == "" then def.groups.stair = 1 end