forked from minetest-mods/moreblocks
Make stairplus:register_* functions work without using register_all.
This commit is contained in:
parent
f02a871c30
commit
54a7102291
@ -102,9 +102,11 @@ function circular_saw:get_output_inv(modname, material, amount, max)
|
|||||||
local t = circular_saw.names[i]
|
local t = circular_saw.names[i]
|
||||||
local cost = circular_saw.cost_in_microblocks[i]
|
local cost = circular_saw.cost_in_microblocks[i]
|
||||||
local balance = math.min(math.floor(amount/cost), max)
|
local balance = math.min(math.floor(amount/cost), max)
|
||||||
pos = pos + 1
|
local nodename = modname .. ":" .. t[1] .. "_" .. material .. t[2]
|
||||||
list[pos] = modname .. ":" .. t[1] .. "_" .. material .. t[2]
|
if minetest.registered_nodes[nodename] then
|
||||||
.. " " .. balance
|
pos = pos + 1
|
||||||
|
list[pos] = nodename .. " " .. balance
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return list
|
return list
|
||||||
end
|
end
|
||||||
|
@ -17,19 +17,28 @@ and minetest.setting_getbool("creative_mode") then
|
|||||||
stairsplus.expect_infinite_stacks = true
|
stairsplus.expect_infinite_stacks = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function stairsplus:register_all(modname, subname, recipeitem, fields)
|
function stairsplus:prepare_groups(groups)
|
||||||
fields = fields or {}
|
result = {}
|
||||||
fields.groups = fields.groups or {}
|
if groups then
|
||||||
if not moreblocks.config.stairsplus_in_creative_inventory then
|
for k, v in pairs(groups) do
|
||||||
fields.groups.not_in_creative_inventory = 1
|
if k ~= "wood" and k ~= "stone" then
|
||||||
|
result[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
if not moreblocks.config.stairsplus_in_creative_inventory then
|
||||||
|
result.not_in_creative_inventory = 1
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
function stairsplus:register_all(modname, subname, recipeitem, fields)
|
||||||
self:register_stair(modname, subname, recipeitem, fields)
|
self:register_stair(modname, subname, recipeitem, fields)
|
||||||
self:register_slab (modname, subname, recipeitem, fields)
|
self:register_slab (modname, subname, recipeitem, fields)
|
||||||
self:register_slope(modname, subname, recipeitem, fields)
|
self:register_slope(modname, subname, recipeitem, fields)
|
||||||
self:register_panel(modname, subname, recipeitem, fields)
|
self:register_panel(modname, subname, recipeitem, fields)
|
||||||
self:register_micro(modname, subname, recipeitem, fields)
|
self:register_micro(modname, subname, recipeitem, fields)
|
||||||
-- self:register_6dfacedir_conversion(modname, subname) -- Not needed as of Q3 2013, uncomment to fix old maps.
|
-- self:register_6dfacedir_conversion(modname, subname) -- Not needed as of Q3 2013, uncomment to fix old maps.
|
||||||
circular_saw.known_nodes[recipeitem] = {modname, subname}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function register_stair_slab_panel_micro(modname, subname, recipeitem, groups, images, description, drop, light)
|
function register_stair_slab_panel_micro(modname, subname, recipeitem, groups, images, description, drop, light)
|
||||||
|
@ -10,7 +10,7 @@ local S = moreblocks.intllib
|
|||||||
-- Node will be called <modname>:micro_<subname>
|
-- Node will be called <modname>:micro_<subname>
|
||||||
|
|
||||||
function register_micro(modname, subname, recipeitem, groups, images, description, drop, light)
|
function register_micro(modname, subname, recipeitem, groups, images, description, drop, light)
|
||||||
return stairsplus:register_micro(modname, subname, recipeitem, {
|
stairsplus:register_micro(modname, subname, recipeitem, {
|
||||||
groups = groups,
|
groups = groups,
|
||||||
tiles = images,
|
tiles = images,
|
||||||
description = description,
|
description = description,
|
||||||
@ -68,22 +68,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
|
||||||
|
def[k] = v
|
||||||
|
end
|
||||||
def.drawtype = "nodebox"
|
def.drawtype = "nodebox"
|
||||||
def.paramtype = "light"
|
def.paramtype = "light"
|
||||||
def.paramtype2 = "facedir"
|
def.paramtype2 = "facedir"
|
||||||
def.on_place = minetest.rotate_node
|
def.on_place = minetest.rotate_node
|
||||||
for k, v in pairs(fields) do
|
def.groups = stairsplus:prepare_groups(fields.groups)
|
||||||
def[k] = v
|
|
||||||
end
|
|
||||||
def.description = desc
|
def.description = desc
|
||||||
if fields.drop then
|
if fields.drop then
|
||||||
def.drop = modname.. ":micro_" ..fields.drop..alternate
|
def.drop = modname.. ":micro_" ..fields.drop..alternate
|
||||||
end
|
end
|
||||||
minetest.register_node(":" ..modname.. ":micro_" ..subname..alternate, def)
|
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)
|
||||||
|
|
||||||
|
circular_saw.known_nodes[recipeitem] = {modname, subname}
|
||||||
|
|
||||||
-- Some saw-less recipes:
|
-- Some saw-less recipes:
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -10,7 +10,7 @@ local S = moreblocks.intllib
|
|||||||
-- Node will be called <modname>:panel_<subname>
|
-- Node will be called <modname>:panel_<subname>
|
||||||
|
|
||||||
function register_panel(modname, subname, recipeitem, groups, images, description, drop, light)
|
function register_panel(modname, subname, recipeitem, groups, images, description, drop, light)
|
||||||
return stairsplus:register_panel(modname, subname, recipeitem, {
|
stairsplus:register_panel(modname, subname, recipeitem, {
|
||||||
groups = groups,
|
groups = groups,
|
||||||
tiles = images,
|
tiles = images,
|
||||||
description = description,
|
description = description,
|
||||||
@ -68,14 +68,15 @@ 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
|
||||||
|
def[k] = v
|
||||||
|
end
|
||||||
def.drawtype = "nodebox"
|
def.drawtype = "nodebox"
|
||||||
def.paramtype = "light"
|
def.paramtype = "light"
|
||||||
def.paramtype2 = "facedir"
|
def.paramtype2 = "facedir"
|
||||||
def.on_place = minetest.rotate_node
|
def.on_place = minetest.rotate_node
|
||||||
for k, v in pairs(fields) do
|
|
||||||
def[k] = v
|
|
||||||
end
|
|
||||||
def.description = desc
|
def.description = desc
|
||||||
|
def.groups = stairsplus:prepare_groups(fields.groups)
|
||||||
if fields.drop then
|
if fields.drop then
|
||||||
def.drop = modname.. ":panel_" ..fields.drop..alternate
|
def.drop = modname.. ":panel_" ..fields.drop..alternate
|
||||||
end
|
end
|
||||||
@ -83,6 +84,8 @@ function stairsplus:register_panel(modname, subname, recipeitem, fields)
|
|||||||
end
|
end
|
||||||
minetest.register_alias(modname.. ":panel_" ..subname.. "_bottom", modname.. ":panel_" ..subname)
|
minetest.register_alias(modname.. ":panel_" ..subname.. "_bottom", modname.. ":panel_" ..subname)
|
||||||
|
|
||||||
|
circular_saw.known_nodes[recipeitem] = {modname, subname}
|
||||||
|
|
||||||
-- Some saw-less recipes:
|
-- Some saw-less recipes:
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -40,13 +40,6 @@ for _, name in pairs(default_nodes) do
|
|||||||
local nodename = "default:" .. name
|
local nodename = "default:" .. name
|
||||||
local ndef = minetest.registered_nodes[nodename]
|
local ndef = minetest.registered_nodes[nodename]
|
||||||
if ndef then
|
if ndef then
|
||||||
local groups = {}
|
|
||||||
for k, v in pairs(ndef.groups)
|
|
||||||
-- Ignore wood and stone groups to not make them usable in crafting:
|
|
||||||
do if k ~= "wood" and k ~= "stone" then
|
|
||||||
groups[k] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local drop
|
local drop
|
||||||
if type(ndef.drop) == "string" then
|
if type(ndef.drop) == "string" then
|
||||||
drop = ndef.drop:sub(9)
|
drop = ndef.drop:sub(9)
|
||||||
@ -54,7 +47,7 @@ for _, name in pairs(default_nodes) do
|
|||||||
stairsplus:register_all("moreblocks", name, nodename, {
|
stairsplus:register_all("moreblocks", name, nodename, {
|
||||||
description = ndef.description,
|
description = ndef.description,
|
||||||
drop = drop,
|
drop = drop,
|
||||||
groups = groups,
|
groups = ndef.groups,
|
||||||
sounds = ndef.sounds,
|
sounds = ndef.sounds,
|
||||||
tiles = ndef.tiles,
|
tiles = ndef.tiles,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
|
@ -10,7 +10,7 @@ local S = moreblocks.intllib
|
|||||||
-- Node will be called <modname>:slab_<subname>
|
-- Node will be called <modname>:slab_<subname>
|
||||||
|
|
||||||
function register_slab(modname, subname, recipeitem, groups, images, description, drop, light)
|
function register_slab(modname, subname, recipeitem, groups, images, description, drop, light)
|
||||||
return stairsplus:register_slab(modname, subname, recipeitem, {
|
stairsplus:register_slab(modname, subname, recipeitem, {
|
||||||
groups = groups,
|
groups = groups,
|
||||||
tiles = images,
|
tiles = images,
|
||||||
description = description,
|
description = description,
|
||||||
@ -30,6 +30,7 @@ function stairsplus:register_slab(modname, subname, recipeitem, fields)
|
|||||||
["_14"] = 14,
|
["_14"] = 14,
|
||||||
["_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 = {
|
local def = {
|
||||||
@ -38,14 +39,15 @@ function stairsplus:register_slab(modname, subname, recipeitem, fields)
|
|||||||
fixed = {-0.5, -0.5, -0.5, 0.5, (num/16)-0.5, 0.5},
|
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
|
||||||
|
end
|
||||||
def.drawtype = "nodebox"
|
def.drawtype = "nodebox"
|
||||||
def.paramtype = "light"
|
def.paramtype = "light"
|
||||||
def.paramtype2 = "facedir"
|
def.paramtype2 = "facedir"
|
||||||
def.on_place = minetest.rotate_node
|
def.on_place = minetest.rotate_node
|
||||||
for k, v in pairs(fields) do
|
|
||||||
def[k] = v
|
|
||||||
end
|
|
||||||
def.description = ("%s (%d/16)"):format(desc_base, num)
|
def.description = ("%s (%d/16)"):format(desc_base, num)
|
||||||
|
def.groups = stairsplus:prepare_groups(fields.groups)
|
||||||
if fields.drop then
|
if fields.drop then
|
||||||
def.drop = modname.. ":slab_" .. fields.drop .. alternate
|
def.drop = modname.. ":slab_" .. fields.drop .. alternate
|
||||||
end
|
end
|
||||||
@ -53,6 +55,8 @@ function stairsplus:register_slab(modname, subname, recipeitem, fields)
|
|||||||
end
|
end
|
||||||
minetest.register_alias("stairs:slab_" .. subname, modname .. ":slab_" .. subname)
|
minetest.register_alias("stairs:slab_" .. subname, modname .. ":slab_" .. subname)
|
||||||
|
|
||||||
|
circular_saw.known_nodes[recipeitem] = {modname, subname}
|
||||||
|
|
||||||
-- Some saw-less recipes:
|
-- Some saw-less recipes:
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -113,7 +113,7 @@ local box_slope_outer_half_raised = {
|
|||||||
-- Node will be called <modname>:slope_<subname>
|
-- Node will be called <modname>:slope_<subname>
|
||||||
|
|
||||||
function register_slope(modname, subname, recipeitem, groups, images, description, drop, light)
|
function register_slope(modname, subname, recipeitem, groups, images, description, drop, light)
|
||||||
return stairsplus:register_slope(modname, subname, recipeitem, {
|
stairsplus:register_slope(modname, subname, recipeitem, {
|
||||||
groups = groups,
|
groups = groups,
|
||||||
tiles = images,
|
tiles = images,
|
||||||
description = description,
|
description = description,
|
||||||
@ -222,20 +222,23 @@ function stairsplus:register_slope(modname, subname, recipeitem, fields)
|
|||||||
|
|
||||||
local desc = S("%s Slope"):format(fields.description)
|
local desc = S("%s Slope"):format(fields.description)
|
||||||
for alternate, def in pairs(defs) do
|
for alternate, def in pairs(defs) do
|
||||||
|
for k, v in pairs(fields) do
|
||||||
|
def[k] = v
|
||||||
|
end
|
||||||
def.drawtype = "mesh"
|
def.drawtype = "mesh"
|
||||||
def.paramtype = "light"
|
def.paramtype = "light"
|
||||||
def.paramtype2 = "facedir"
|
def.paramtype2 = "facedir"
|
||||||
def.on_place = minetest.rotate_node
|
def.on_place = minetest.rotate_node
|
||||||
for k, v in pairs(fields) do
|
|
||||||
def[k] = v
|
|
||||||
end
|
|
||||||
def.description = desc
|
def.description = desc
|
||||||
|
def.groups = stairsplus:prepare_groups(fields.groups)
|
||||||
if fields.drop then
|
if fields.drop then
|
||||||
def.drop = modname.. ":slope_" ..fields.drop..alternate
|
def.drop = modname.. ":slope_" ..fields.drop..alternate
|
||||||
end
|
end
|
||||||
minetest.register_node(":" ..modname.. ":slope_" ..subname..alternate, def)
|
minetest.register_node(":" ..modname.. ":slope_" ..subname..alternate, def)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
circular_saw.known_nodes[recipeitem] = {modname, subname}
|
||||||
|
|
||||||
-- Some saw-less recipes:
|
-- Some saw-less recipes:
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -10,7 +10,7 @@ local S = moreblocks.intllib
|
|||||||
-- Node will be called <modname>:stair_<subname>
|
-- Node will be called <modname>:stair_<subname>
|
||||||
|
|
||||||
function register_stair(modname, subname, recipeitem, groups, images, description, drop, light)
|
function register_stair(modname, subname, recipeitem, groups, images, description, drop, light)
|
||||||
return stairsplus:register_stair(modname, subname, recipeitem, {
|
stairsplus:register_stair(modname, subname, recipeitem, {
|
||||||
groups = groups,
|
groups = groups,
|
||||||
tiles = images,
|
tiles = images,
|
||||||
description = description,
|
description = description,
|
||||||
@ -108,14 +108,15 @@ 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
|
||||||
|
def[k] = v
|
||||||
|
end
|
||||||
def.drawtype = "nodebox"
|
def.drawtype = "nodebox"
|
||||||
def.paramtype = "light"
|
def.paramtype = "light"
|
||||||
def.paramtype2 = "facedir"
|
def.paramtype2 = "facedir"
|
||||||
def.on_place = minetest.rotate_node
|
def.on_place = minetest.rotate_node
|
||||||
for k, v in pairs(fields) do
|
|
||||||
def[k] = v
|
|
||||||
end
|
|
||||||
def.description = desc
|
def.description = desc
|
||||||
|
def.groups = stairsplus:prepare_groups(fields.groups)
|
||||||
if fields.drop then
|
if fields.drop then
|
||||||
def.drop = modname .. ":stair_" .. fields.drop .. alternate
|
def.drop = modname .. ":stair_" .. fields.drop .. alternate
|
||||||
end
|
end
|
||||||
@ -123,6 +124,8 @@ function stairsplus:register_stair(modname, subname, recipeitem, fields)
|
|||||||
end
|
end
|
||||||
minetest.register_alias("stairs:stair_" .. subname, modname .. ":stair_" .. subname)
|
minetest.register_alias("stairs:stair_" .. subname, modname .. ":stair_" .. subname)
|
||||||
|
|
||||||
|
circular_saw.known_nodes[recipeitem] = {modname, subname}
|
||||||
|
|
||||||
-- Some saw-less recipes:
|
-- Some saw-less recipes:
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
Loading…
Reference in New Issue
Block a user