From 795f029809e395e5c6533a8be2b630bc29a9fee0 Mon Sep 17 00:00:00 2001 From: Marcin Date: Sat, 27 Jun 2015 12:07:31 +0200 Subject: [PATCH] Comments --- stairsplus/panels.lua | 18 +++++---- stairsplus/registrations.lua | 12 ++++-- stairsplus/slabs.lua | 74 +++++++++++++++++++----------------- 3 files changed, 60 insertions(+), 44 deletions(-) diff --git a/stairsplus/panels.lua b/stairsplus/panels.lua index 2220fe4..efc6d10 100644 --- a/stairsplus/panels.lua +++ b/stairsplus/panels.lua @@ -22,43 +22,43 @@ end function stairsplus:register_panel(modname, subname, recipeitem, fields) local defs = { - [""] = { + [""] = { -- 8/16 high (default panel) node_box = { type = "fixed", fixed = {-0.5, -0.5, 0, 0.5, 0, 0.5}, }, }, - ["_1"] = { + ["_1"] = { -- 1/16 high node_box = { type = "fixed", fixed = {-0.5, -0.5, 0, 0.5, -0.4375, 0.5}, }, }, - ["_2"] = { + ["_2"] = { -- 2/16 high node_box = { type = "fixed", fixed = {-0.5, -0.5, 0, 0.5, -0.375, 0.5}, }, }, - ["_4"] = { + ["_4"] = { -- 4/16 high node_box = { type = "fixed", fixed = {-0.5, -0.5, 0, 0.5, -0.25, 0.5}, }, }, - ["_12"] = { + ["_12"] = { -- 12/16 high node_box = { type = "fixed", fixed = {-0.5, -0.5, 0, 0.5, 0.25, 0.5}, }, }, - ["_14"] = { + ["_14"] = { -- 14/16 high node_box = { type = "fixed", fixed = {-0.5, -0.5, 0, 0.5, 0.375, 0.5}, }, }, - ["_15"] = { + ["_15"] = { -- 15/16 high node_box = { type = "fixed", fixed = {-0.5, -0.5, 0, 0.5, 0.4375, 0.5}, @@ -85,6 +85,7 @@ function stairsplus:register_panel(modname, subname, recipeitem, fields) -- Some saw-less recipes: + -- 3 blocks shaped to stair -> 12 panels minetest.register_craft({ output = modname .. ":panel_" .. subname .. " 12", recipe = { @@ -93,6 +94,7 @@ function stairsplus:register_panel(modname, subname, recipeitem, fields) }, }) + -- mirrored rule from above minetest.register_craft({ output = modname .. ":panel_" .. subname .. " 12", recipe = { @@ -101,12 +103,14 @@ function stairsplus:register_panel(modname, subname, recipeitem, fields) }, }) + -- 2 microblocks -> panel minetest.register_craft({ type = "shapeless", output = modname .. ":panel_" .. subname, recipe = {modname .. ":micro_" .. subname, modname .. ":micro_" .. subname}, }) + -- 4 panels -> full block minetest.register_craft({ type = "shapeless", output = recipeitem, diff --git a/stairsplus/registrations.lua b/stairsplus/registrations.lua index ee658da..147ab87 100644 --- a/stairsplus/registrations.lua +++ b/stairsplus/registrations.lua @@ -36,18 +36,25 @@ local default_nodes = { -- Default stairs/slabs/panels/microblocks: for _, name in pairs(default_nodes) do local nodename = "default:" .. name local ndef = minetest.registered_nodes[nodename] + if ndef then local groups = {} - for k, v in pairs(ndef.groups) + + for k, v in pairs(ndef.groups) do -- Ignore wood and stone groups to not make them usable in crafting: - do if k ~= "wood" and k ~= "stone" then + if k ~= "wood" and k ~= "stone" then groups[k] = v end end + local drop + + -- Take string part after "default:" since we want to register + -- things in microblocks namespace instead of default if type(ndef.drop) == "string" then drop = ndef.drop:sub(9) end + stairsplus:register_all("moreblocks", name, nodename, { description = ndef.description, drop = drop, @@ -58,4 +65,3 @@ for _, name in pairs(default_nodes) do }) end end - diff --git a/stairsplus/slabs.lua b/stairsplus/slabs.lua index 9777ac2..f20ffa3 100644 --- a/stairsplus/slabs.lua +++ b/stairsplus/slabs.lua @@ -55,39 +55,45 @@ function stairsplus:register_slab(modname, subname, recipeitem, fields) -- Some saw-less recipes: - minetest.register_craft({ - output = modname .. ":slab_" .. subname .. " 6", - recipe = {{recipeitem, recipeitem, recipeitem}}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname, - recipe = {modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname}, - }) - - minetest.register_craft({ - output = modname .. ":slab_" .. subname, - recipe = {{modname .. ":panel_" .. subname, modname .. ":panel_" .. subname}}, - }) - - minetest.register_craft({ - output = modname .. ":slab_" .. subname, - recipe = { - {modname .. ":panel_" .. subname}, - {modname .. ":panel_" .. subname}, - }, - }) + -- 3 full blocks -> 6 slabs + minetest.register_craft({ + output = modname .. ":slab_" .. subname .. " 6", + recipe = {{recipeitem, recipeitem, recipeitem}}, + }) + + -- 4 microblocks -> slab + minetest.register_craft({ + type = "shapeless", + output = modname .. ":slab_" .. subname, + recipe = {modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname}, + }) + + -- 2 panels -> slab + minetest.register_craft({ + output = modname .. ":slab_" .. subname, + recipe = {{modname .. ":panel_" .. subname, modname .. ":panel_" .. subname}}, + }) + + -- same as above but vertically + minetest.register_craft({ + output = modname .. ":slab_" .. subname, + recipe = { + {modname .. ":panel_" .. subname}, + {modname .. ":panel_" .. subname}, + }, + }) - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":slab_" .. subname, modname .. ":slab_" .. subname}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname .. " 3", - recipe = {modname .. ":stair_" .. subname, modname .. ":stair_" .. subname}, - }) + -- 2 slabs -> full block + minetest.register_craft({ + type = "shapeless", + output = recipeitem, + recipe = {modname .. ":slab_" .. subname, modname .. ":slab_" .. subname}, + }) + + -- 2 stairs -> 3 slabs + minetest.register_craft({ + type = "shapeless", + output = modname .. ":slab_" .. subname .. " 3", + recipe = {modname .. ":stair_" .. subname, modname .. ":stair_" .. subname}, + }) end