1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-03-28 15:20:47 +01:00

[moreblocks] Remove and alias some cut nodes

This commit is contained in:
LeMagnesium 2016-05-07 20:06:18 +02:00
parent 60b52b806b
commit a253f5478d
5 changed files with 96 additions and 115 deletions

View File

@ -31,36 +31,33 @@ circular_saw.cost_in_microblocks = {
6, 2, 1, 3, 4, 6, 2, 1, 3, 4,
} }
-- This parameter is legacy node
circular_saw.names = { circular_saw.names = {
{"micro", "_1"}, {"micro", "_1"},
{"panel", "_1"}, {"panel", "_1"},
{"micro", "_2"},
{"panel", "_2"},
{"micro", "_4"},
{"panel", "_4"},
{"micro", ""}, {"micro", ""},
{"panel", ""}, {"panel", ""},
{"micro", "_12"}, {"micro", "_12"},
{"panel", "_12"}, {"panel", "_12"},
{"micro", "_14"},
{"panel", "_14"},
{"micro", "_15"}, {"micro", "_15"},
{"panel", "_15"}, {"panel", "_15"},
{"stair", "_outer"}, {"stair", "_outer"},
{"stair", ""}, {"stair", ""},
{"stair", "_inner"}, {"stair", "_inner"},
{"slab", "_1"}, {"slab", "_1"},
{"slab", "_2"},
{"slab", "_quarter"}, {"slab", "_quarter"},
{"slab", ""}, {"slab", ""},
{"slab", "_three_quarter"}, {"slab", "_three_quarter"},
{"slab", "_14"},
{"slab", "_15"}, {"slab", "_15"},
{"stair", "_half"}, {"stair", "_half"},
{"stair", "_alt_1"}, {"stair", "_alt_1"},
{"stair", "_alt_2"},
{"stair", "_alt_4"}, {"stair", "_alt_4"},
{"stair", "_alt"}, {"stair", "_alt"},
{"slope", ""}, {"slope", ""},
{"slope", "_half"}, {"slope", "_half"},
{"slope", "_half_raised"}, {"slope", "_half_raised"},
@ -100,12 +97,14 @@ function circular_saw:get_output_inv(modname, material, amount, max)
for i = 1, #circular_saw.names do for i = 1, #circular_saw.names do
local t = circular_saw.names[i] local t = circular_saw.names[i]
local cost = circular_saw.cost_in_microblocks[i] if not t[3] then
local balance = math.min(math.floor(amount/cost), max) local cost = circular_saw.cost_in_microblocks[i]
local nodename = modname .. ":" .. t[1] .. "_" .. material .. t[2] local balance = math.min(math.floor(amount/cost), max)
if minetest.registered_nodes[nodename] then local nodename = modname .. ":" .. t[1] .. "_" .. material .. t[2]
pos = pos + 1 if minetest.registered_nodes[nodename] then
list[pos] = nodename .. " " .. balance pos = pos + 1
list[pos] = nodename .. " " .. balance
end
end end
end end
return list return list

View File

@ -34,30 +34,15 @@ function stairsplus:register_micro(modname, subname, recipeitem, fields)
fixed = {-0.5, -0.5, 0, 0, -0.4375, 0.5}, fixed = {-0.5, -0.5, 0, 0, -0.4375, 0.5},
}, },
}, },
["_2"] = { ["_2"] = {legacy = "_1"},
node_box = { ["_4"] = {legacy = ""},
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},
},
},
["_12"] = { ["_12"] = {
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = {-0.5, -0.5, 0, 0, 0.25, 0.5}, fixed = {-0.5, -0.5, 0, 0, 0.25, 0.5},
}, },
}, },
["_14"] = { ["_14"] = {legacy = "_15"},
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, 0.375, 0.5},
},
},
["_15"] = { ["_15"] = {
node_box = { node_box = {
type = "fixed", type = "fixed",
@ -68,19 +53,24 @@ function stairsplus:register_micro(modname, subname, recipeitem, fields)
local desc = S("%s Microblock"):format(fields.description) local desc = S("%s Microblock"):format(fields.description)
for alternate, def in pairs(defs) do for alternate, def in pairs(defs) do
for k, v in pairs(fields) do if def.legacy then
def[k] = v 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 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 end
minetest.register_alias(modname.. ":micro_" ..subname.. "_bottom", modname.. ":micro_" ..subname) minetest.register_alias(modname.. ":micro_" ..subname.. "_bottom", modname.. ":micro_" ..subname)

View File

@ -34,30 +34,15 @@ function stairsplus:register_panel(modname, subname, recipeitem, fields)
fixed = {-0.5, -0.5, 0, 0.5, -0.4375, 0.5}, fixed = {-0.5, -0.5, 0, 0.5, -0.4375, 0.5},
}, },
}, },
["_2"] = { ["_2"] = {legacy = "_1"},
node_box = { ["_4"] = {legacy = ""},
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},
},
},
["_12"] = { ["_12"] = {
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, 0.25, 0.5}, fixed = {-0.5, -0.5, 0, 0.5, 0.25, 0.5},
}, },
}, },
["_14"] = { ["_14"] = {legacy = "_15"},
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, 0.375, 0.5},
},
},
["_15"] = { ["_15"] = {
node_box = { node_box = {
type = "fixed", type = "fixed",
@ -68,19 +53,24 @@ function stairsplus:register_panel(modname, subname, recipeitem, fields)
local desc = S("%s Panel"):format(fields.description) local desc = S("%s Panel"):format(fields.description)
for alternate, def in pairs(defs) do for alternate, def in pairs(defs) do
for k, v in pairs(fields) do if def.legacy then
def[k] = v 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 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 end
minetest.register_alias(modname.. ":panel_" ..subname.. "_bottom", modname.. ":panel_" ..subname) minetest.register_alias(modname.. ":panel_" ..subname.. "_bottom", modname.. ":panel_" ..subname)

View File

@ -26,32 +26,37 @@ function stairsplus:register_slab(modname, subname, recipeitem, fields)
["_quarter"] = 4, ["_quarter"] = 4,
["_three_quarter"] = 12, ["_three_quarter"] = 12,
["_1"] = 1, ["_1"] = 1,
["_2"] = 2, ["_2"] = "_1",
["_14"] = 14, ["_14"] = "_three_quarter",
["_15"] = 15, ["_15"] = 15,
} }
local desc_base = S("%s Slab"):format(fields.description) local desc_base = S("%s Slab"):format(fields.description)
for alternate, num in pairs(defs) do for alternate, num in pairs(defs) do
local def = { if type(num) == type("moo") then
node_box = { minetest.register_alias(modname .. ":slab_" .. subname .. alternate,
type = "fixed", modname .. ":slab_" .. subname .. num)
fixed = {-0.5, -0.5, -0.5, 0.5, (num/16)-0.5, 0.5}, 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
for k, v in pairs(fields) do def[k] = v
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 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 end
minetest.register_alias("stairs:slab_" .. subname, modname .. ":slab_" .. subname) minetest.register_alias("stairs:slab_" .. subname, modname .. ":slab_" .. subname)

View File

@ -86,15 +86,7 @@ function stairsplus:register_stair(modname, subname, recipeitem, fields)
}, },
}, },
}, },
["_alt_2"] = { ["_alt_2"] = {legacy = "_alt_1"},
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_4"] = { ["_alt_4"] = {
node_box = { node_box = {
type = "fixed", type = "fixed",
@ -108,19 +100,24 @@ function stairsplus:register_stair(modname, subname, recipeitem, fields)
local desc = S("%s Stairs"):format(fields.description) local desc = S("%s Stairs"):format(fields.description)
for alternate, def in pairs(defs) do for alternate, def in pairs(defs) do
for k, v in pairs(fields) do if def.legacy then
def[k] = v 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 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 end
minetest.register_alias("stairs:stair_" .. subname, modname .. ":stair_" .. subname) minetest.register_alias("stairs:stair_" .. subname, modname .. ":stair_" .. subname)