From a253f5478df7964a3ab1b27540766e44a45209c8 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Sat, 7 May 2016 20:06:18 +0200 Subject: [PATCH] [moreblocks] Remove and alias some cut nodes --- mods/moreblocks/circular_saw.lua | 29 ++++++------- mods/moreblocks/stairsplus/microblocks.lua | 50 +++++++++------------- mods/moreblocks/stairsplus/panels.lua | 50 +++++++++------------- mods/moreblocks/stairsplus/slabs.lua | 43 +++++++++++-------- mods/moreblocks/stairsplus/stairs.lua | 39 ++++++++--------- 5 files changed, 96 insertions(+), 115 deletions(-) diff --git a/mods/moreblocks/circular_saw.lua b/mods/moreblocks/circular_saw.lua index d676c3bb..343f2d63 100755 --- a/mods/moreblocks/circular_saw.lua +++ b/mods/moreblocks/circular_saw.lua @@ -31,36 +31,33 @@ circular_saw.cost_in_microblocks = { 6, 2, 1, 3, 4, } +-- This parameter is legacy node circular_saw.names = { {"micro", "_1"}, {"panel", "_1"}, - {"micro", "_2"}, - {"panel", "_2"}, - {"micro", "_4"}, - {"panel", "_4"}, {"micro", ""}, {"panel", ""}, + {"micro", "_12"}, {"panel", "_12"}, - {"micro", "_14"}, - {"panel", "_14"}, {"micro", "_15"}, {"panel", "_15"}, + {"stair", "_outer"}, {"stair", ""}, {"stair", "_inner"}, + {"slab", "_1"}, - {"slab", "_2"}, {"slab", "_quarter"}, {"slab", ""}, {"slab", "_three_quarter"}, - {"slab", "_14"}, {"slab", "_15"}, + {"stair", "_half"}, {"stair", "_alt_1"}, - {"stair", "_alt_2"}, {"stair", "_alt_4"}, {"stair", "_alt"}, + {"slope", ""}, {"slope", "_half"}, {"slope", "_half_raised"}, @@ -100,12 +97,14 @@ function circular_saw:get_output_inv(modname, material, amount, max) for i = 1, #circular_saw.names do local t = circular_saw.names[i] - local cost = circular_saw.cost_in_microblocks[i] - local balance = math.min(math.floor(amount/cost), max) - local nodename = modname .. ":" .. t[1] .. "_" .. material .. t[2] - if minetest.registered_nodes[nodename] then - pos = pos + 1 - list[pos] = nodename .. " " .. balance + if not t[3] then + local cost = circular_saw.cost_in_microblocks[i] + local balance = math.min(math.floor(amount/cost), max) + local nodename = modname .. ":" .. t[1] .. "_" .. material .. t[2] + if minetest.registered_nodes[nodename] then + pos = pos + 1 + list[pos] = nodename .. " " .. balance + end end end return list diff --git a/mods/moreblocks/stairsplus/microblocks.lua b/mods/moreblocks/stairsplus/microblocks.lua index 4716dbc0..909bfa58 100755 --- a/mods/moreblocks/stairsplus/microblocks.lua +++ b/mods/moreblocks/stairsplus/microblocks.lua @@ -34,30 +34,15 @@ function stairsplus:register_micro(modname, subname, recipeitem, fields) fixed = {-0.5, -0.5, 0, 0, -0.4375, 0.5}, }, }, - ["_2"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0, -0.375, 0.5}, - }, - }, - ["_4"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0, -0.25, 0.5}, - }, - }, + ["_2"] = {legacy = "_1"}, + ["_4"] = {legacy = ""}, ["_12"] = { node_box = { type = "fixed", fixed = {-0.5, -0.5, 0, 0, 0.25, 0.5}, }, }, - ["_14"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0, 0.375, 0.5}, - }, - }, + ["_14"] = {legacy = "_15"}, ["_15"] = { node_box = { type = "fixed", @@ -68,19 +53,24 @@ function stairsplus:register_micro(modname, subname, recipeitem, fields) local desc = S("%s Microblock"):format(fields.description) for alternate, def in pairs(defs) do - for k, v in pairs(fields) do - def[k] = v + if def.legacy then + minetest.register_alias(modname .. ":micro_" .. subname .. alternate, + modname .. ":micro_" .. subname .. def.legacy) + else + for k, v in pairs(fields) do + def[k] = v + end + def.drawtype = "nodebox" + def.paramtype = "light" + def.paramtype2 = "facedir" + def.on_place = minetest.rotate_node + def.groups = stairsplus:prepare_groups(fields.groups) + def.description = desc + if fields.drop then + def.drop = modname.. ":micro_" ..fields.drop..alternate + end + minetest.register_node(":" ..modname.. ":micro_" ..subname..alternate, def) end - def.drawtype = "nodebox" - def.paramtype = "light" - def.paramtype2 = "facedir" - def.on_place = minetest.rotate_node - def.groups = stairsplus:prepare_groups(fields.groups) - def.description = desc - if fields.drop then - def.drop = modname.. ":micro_" ..fields.drop..alternate - end - minetest.register_node(":" ..modname.. ":micro_" ..subname..alternate, def) end minetest.register_alias(modname.. ":micro_" ..subname.. "_bottom", modname.. ":micro_" ..subname) diff --git a/mods/moreblocks/stairsplus/panels.lua b/mods/moreblocks/stairsplus/panels.lua index 22d892c8..47a53ccf 100755 --- a/mods/moreblocks/stairsplus/panels.lua +++ b/mods/moreblocks/stairsplus/panels.lua @@ -34,30 +34,15 @@ function stairsplus:register_panel(modname, subname, recipeitem, fields) fixed = {-0.5, -0.5, 0, 0.5, -0.4375, 0.5}, }, }, - ["_2"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0.5, -0.375, 0.5}, - }, - }, - ["_4"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0.5, -0.25, 0.5}, - }, - }, + ["_2"] = {legacy = "_1"}, + ["_4"] = {legacy = ""}, ["_12"] = { node_box = { type = "fixed", fixed = {-0.5, -0.5, 0, 0.5, 0.25, 0.5}, }, }, - ["_14"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0.5, 0.375, 0.5}, - }, - }, + ["_14"] = {legacy = "_15"}, ["_15"] = { node_box = { type = "fixed", @@ -68,19 +53,24 @@ function stairsplus:register_panel(modname, subname, recipeitem, fields) local desc = S("%s Panel"):format(fields.description) for alternate, def in pairs(defs) do - for k, v in pairs(fields) do - def[k] = v + if def.legacy then + minetest.register_alias(modname .. ":panel_" .. subname .. alternate, + modname .. ":panel_" .. subname .. def.legacy) + else + for k, v in pairs(fields) do + def[k] = v + end + def.drawtype = "nodebox" + def.paramtype = "light" + def.paramtype2 = "facedir" + def.on_place = minetest.rotate_node + def.description = desc + def.groups = stairsplus:prepare_groups(fields.groups) + if fields.drop then + def.drop = modname.. ":panel_" ..fields.drop..alternate + end + minetest.register_node(":" ..modname.. ":panel_" ..subname..alternate, def) end - def.drawtype = "nodebox" - def.paramtype = "light" - def.paramtype2 = "facedir" - def.on_place = minetest.rotate_node - def.description = desc - def.groups = stairsplus:prepare_groups(fields.groups) - if fields.drop then - def.drop = modname.. ":panel_" ..fields.drop..alternate - end - minetest.register_node(":" ..modname.. ":panel_" ..subname..alternate, def) end minetest.register_alias(modname.. ":panel_" ..subname.. "_bottom", modname.. ":panel_" ..subname) diff --git a/mods/moreblocks/stairsplus/slabs.lua b/mods/moreblocks/stairsplus/slabs.lua index ef4244b6..6406c261 100755 --- a/mods/moreblocks/stairsplus/slabs.lua +++ b/mods/moreblocks/stairsplus/slabs.lua @@ -26,32 +26,37 @@ function stairsplus:register_slab(modname, subname, recipeitem, fields) ["_quarter"] = 4, ["_three_quarter"] = 12, ["_1"] = 1, - ["_2"] = 2, - ["_14"] = 14, + ["_2"] = "_1", + ["_14"] = "_three_quarter", ["_15"] = 15, } local desc_base = S("%s Slab"):format(fields.description) for alternate, num in pairs(defs) do - local def = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, -0.5, 0.5, (num/16)-0.5, 0.5}, + if type(num) == type("moo") then + minetest.register_alias(modname .. ":slab_" .. subname .. alternate, + modname .. ":slab_" .. subname .. num) + else + local def = { + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, (num/16)-0.5, 0.5}, + } } - } - for k, v in pairs(fields) do - def[k] = v + for k, v in pairs(fields) do + def[k] = v + end + def.drawtype = "nodebox" + def.paramtype = "light" + def.paramtype2 = "facedir" + def.on_place = minetest.rotate_node + def.description = ("%s (%d/16)"):format(desc_base, num) + def.groups = stairsplus:prepare_groups(fields.groups) + if fields.drop then + def.drop = modname.. ":slab_" .. fields.drop .. alternate + end + minetest.register_node(":" .. modname .. ":slab_" .. subname .. alternate, def) end - def.drawtype = "nodebox" - def.paramtype = "light" - def.paramtype2 = "facedir" - def.on_place = minetest.rotate_node - def.description = ("%s (%d/16)"):format(desc_base, num) - def.groups = stairsplus:prepare_groups(fields.groups) - if fields.drop then - def.drop = modname.. ":slab_" .. fields.drop .. alternate - end - minetest.register_node(":" .. modname .. ":slab_" .. subname .. alternate, def) end minetest.register_alias("stairs:slab_" .. subname, modname .. ":slab_" .. subname) diff --git a/mods/moreblocks/stairsplus/stairs.lua b/mods/moreblocks/stairsplus/stairs.lua index 33b443e6..115b1fc6 100755 --- a/mods/moreblocks/stairsplus/stairs.lua +++ b/mods/moreblocks/stairsplus/stairs.lua @@ -86,15 +86,7 @@ function stairsplus:register_stair(modname, subname, recipeitem, fields) }, }, }, - ["_alt_2"] = { - node_box = { - type = "fixed", - fixed = { - {-0.5, -0.125, -0.5, 0.5, 0, 0}, - {-0.5, 0.375, 0, 0.5, 0.5, 0.5}, - }, - }, - }, + ["_alt_2"] = {legacy = "_alt_1"}, ["_alt_4"] = { node_box = { type = "fixed", @@ -108,19 +100,24 @@ function stairsplus:register_stair(modname, subname, recipeitem, fields) local desc = S("%s Stairs"):format(fields.description) for alternate, def in pairs(defs) do - for k, v in pairs(fields) do - def[k] = v + if def.legacy then + minetest.register_alias(modname .. ":stair_" .. subname .. alternate, + modname .. ":stair_" .. subname .. def.legacy) + else + for k, v in pairs(fields) do + def[k] = v + end + def.drawtype = "nodebox" + def.paramtype = "light" + def.paramtype2 = "facedir" + def.on_place = minetest.rotate_node + def.description = desc + def.groups = stairsplus:prepare_groups(fields.groups) + if fields.drop then + def.drop = modname .. ":stair_" .. fields.drop .. alternate + end + minetest.register_node(":" .. modname .. ":stair_" .. subname .. alternate, def) end - def.drawtype = "nodebox" - def.paramtype = "light" - def.paramtype2 = "facedir" - def.on_place = minetest.rotate_node - def.description = desc - def.groups = stairsplus:prepare_groups(fields.groups) - if fields.drop then - def.drop = modname .. ":stair_" .. fields.drop .. alternate - end - minetest.register_node(":" .. modname .. ":stair_" .. subname .. alternate, def) end minetest.register_alias("stairs:stair_" .. subname, modname .. ":stair_" .. subname)