aboutsummaryrefslogtreecommitdiff
path: root/stairsplus
diff options
context:
space:
mode:
authorCalinou <calinou@opmbx.org>2014-03-09 10:38:18 +0100
committerCalinou <calinou@opmbx.org>2014-03-09 10:38:18 +0100
commit8337a6c192b9961f8947767690c13951696c3c1e (patch)
tree77908db80dd8f13b494030203be725e03f96bea8 /stairsplus
parent396945ed3eaf43404bd117bbf4820ce08584cc4e (diff)
downloadmoreblocks-8337a6c192b9961f8947767690c13951696c3c1e.tar.gz
moreblocks-8337a6c192b9961f8947767690c13951696c3c1e.tar.bz2
moreblocks-8337a6c192b9961f8947767690c13951696c3c1e.zip
Merge ShadowNinja's rewrite.
Diffstat (limited to 'stairsplus')
-rw-r--r--stairsplus/API.md25
-rw-r--r--stairsplus/aliases.lua62
-rw-r--r--stairsplus/conversion.lua132
-rw-r--r--stairsplus/init.lua45
-rw-r--r--stairsplus/microblocks.lua186
-rw-r--r--stairsplus/panels.lua182
-rw-r--r--stairsplus/registrations.lua45
-rw-r--r--stairsplus/slabs.lua218
-rw-r--r--stairsplus/stairs.lua315
9 files changed, 595 insertions, 615 deletions
diff --git a/stairsplus/API.md b/stairsplus/API.md
new file mode 100644
index 0000000..480b848
--- /dev/null
+++ b/stairsplus/API.md
@@ -0,0 +1,25 @@
+API documentation for StairsPlus
+================================
+- - - - - - - - - - - - - - - -
+
+* `stairsplus:register_all(modname, subname, recipeitem, fields)`
+ Registers a stair, slab, panel, microblock, and any other types of
+ microblocks to be added in the future.
+ Also registers the node with the circular saw.
+ Example:
+ ```lua
+ stairsplus:register_all("moreblocks", "wood", "defaut:wood", {
+ description = "Wooden",
+ tiles = {"default_wood.png"},
+ groups = {oddly_breakabe_by_hand=1},
+ sounds = default.node_sound_wood_defaults(),
+ })
+ ```
+The following register only a particular type of microblock.
+You will probably never want to use them directly.
+
+* `stairsplus:register_stair(modname, subname, recipeitem, fields)`
+* `stairsplus:register_slab(modname, subname, recipeitem, fields)`
+* `stairsplus:register_panel(modname, subname, recipeitem, fields)`
+* `stairsplus:register_micro(modname, subname, recipeitem, fields)`
+
diff --git a/stairsplus/aliases.lua b/stairsplus/aliases.lua
index 3fcd867..e197035 100644
--- a/stairsplus/aliases.lua
+++ b/stairsplus/aliases.lua
@@ -1,33 +1,34 @@
-function register_stairsplus_alias(modname, origname, newname)
-minetest.register_alias(modname .. ":slab_" .. origname, "moreblocks:slab_" .. newname)
-minetest.register_alias(modname .. ":slab_" .. origname .. "_inverted", "moreblocks:slab_" .. newname .. "_inverted")
-minetest.register_alias(modname .. ":slab_" .. origname .. "_wall", "moreblocks:slab_" .. newname .. "_wall")
-minetest.register_alias(modname .. ":slab_" .. origname .. "_quarter", "moreblocks:slab_" .. newname .. "_quarter")
-minetest.register_alias(modname .. ":slab_" .. origname .. "_quarter_inverted", "moreblocks:slab_" .. newname .. "_quarter_inverted")
-minetest.register_alias(modname .. ":slab_" .. origname .. "_quarter_wall", "moreblocks:slab_" .. newname .. "_quarter_wall")
-minetest.register_alias(modname .. ":slab_" .. origname .. "_three_quarter", "moreblocks:slab_" .. newname .. "_three_quarter")
-minetest.register_alias(modname .. ":slab_" .. origname .. "_three_quarter_inverted", "moreblocks:slab_" .. newname .. "_three_quarter_inverted")
-minetest.register_alias(modname .. ":slab_" .. origname .. "_three_quarter_wall", "moreblocks:slab_" .. newname .. "_three_quarter_wall")
-minetest.register_alias(modname .. ":stair_" .. origname, "moreblocks:stair_" .. newname)
-minetest.register_alias(modname .. ":stair_" .. origname .. "_inverted", "moreblocks:stair_" .. newname .. "_inverted")
-minetest.register_alias(modname .. ":stair_" .. origname .. "_wall", "moreblocks:stair_" .. newname .. "_wall")
-minetest.register_alias(modname .. ":stair_" .. origname .. "_wall_half", "moreblocks:stair_" .. newname .. "_wall_half")
-minetest.register_alias(modname .. ":stair_" .. origname .. "_wall_half_inverted", "moreblocks:stair_" .. newname .. "_wall_half_inverted")
-minetest.register_alias(modname .. ":stair_" .. origname .. "_half", "moreblocks:stair_" .. newname .. "_half")
-minetest.register_alias(modname .. ":stair_" .. origname .. "_half_inverted", "moreblocks:stair_" .. newname .. "_half_inverted")
-minetest.register_alias(modname .. ":stair_" .. origname .. "_right_half", "moreblocks:stair_" .. newname .. "_right_half")
-minetest.register_alias(modname .. ":stair_" .. origname .. "_right_half_inverted", "moreblocks:stair_" .. newname .. "_right_half_inverted")
-minetest.register_alias(modname .. ":stair_" .. origname .. "_wall_half", "moreblocks:stair_" .. newname .. "_wall_half")
-minetest.register_alias(modname .. ":stair_" .. origname .. "_wall_half_inverted", "moreblocks:stair_" .. newname .. "_wall_half_inverted")
-minetest.register_alias(modname .. ":stair_" .. origname .. "_inner", "moreblocks:stair_" .. newname .. "_inner")
-minetest.register_alias(modname .. ":stair_" .. origname .. "_inner_inverted", "moreblocks:stair_" .. newname .. "_inner_inverted")
-minetest.register_alias(modname .. ":stair_" .. origname .. "_outer", "moreblocks:stair_" .. newname .. "_outer")
-minetest.register_alias(modname .. ":stair_" .. origname .. "_outer_inverted", "moreblocks:stair_" .. newname .. "_outer_inverted")
-minetest.register_alias(modname .. ":panel_" .. origname .. "_bottom", "moreblocks:panel_" .. newname .. "_bottom")
-minetest.register_alias(modname .. ":panel_" .. origname .. "_top", "moreblocks:panel_" .. newname .. "_top")
-minetest.register_alias(modname .. ":panel_" .. origname .. "_vertical", "moreblocks:panel_" .. newname .. "_vertical")
-minetest.register_alias(modname .. ":micro_" .. origname .. "_bottom", "moreblocks:micro_" .. newname .. "_bottom")
-minetest.register_alias(modname .. ":micro_" .. origname .. "_top", "moreblocks:micro_" .. newname .. "_top")
+
+local function register_stairsplus_alias(modname, origname, newname)
+ minetest.register_alias(modname..":slab_"..origname, "moreblocks:slab_"..newname)
+ minetest.register_alias(modname..":slab_"..origname.."_inverted", "moreblocks:slab_"..newname.."_inverted")
+ minetest.register_alias(modname..":slab_"..origname.."_wall", "moreblocks:slab_"..newname.."_wall")
+ minetest.register_alias(modname..":slab_"..origname.."_quarter", "moreblocks:slab_"..newname.."_quarter")
+ minetest.register_alias(modname..":slab_"..origname.."_quarter_inverted", "moreblocks:slab_"..newname.."_quarter_inverted")
+ minetest.register_alias(modname..":slab_"..origname.."_quarter_wall", "moreblocks:slab_"..newname.."_quarter_wall")
+ minetest.register_alias(modname..":slab_"..origname.."_three_quarter", "moreblocks:slab_"..newname.."_three_quarter")
+ minetest.register_alias(modname..":slab_"..origname.."_three_quarter_inverted", "moreblocks:slab_"..newname.."_three_quarter_inverted")
+ minetest.register_alias(modname..":slab_"..origname.."_three_quarter_wall", "moreblocks:slab_"..newname.."_three_quarter_wall")
+ minetest.register_alias(modname..":stair_"..origname, "moreblocks:stair_"..newname)
+ minetest.register_alias(modname..":stair_"..origname.."_inverted", "moreblocks:stair_"..newname.."_inverted")
+ minetest.register_alias(modname..":stair_"..origname.."_wall", "moreblocks:stair_"..newname.."_wall")
+ minetest.register_alias(modname..":stair_"..origname.."_wall_half", "moreblocks:stair_"..newname.."_wall_half")
+ minetest.register_alias(modname..":stair_"..origname.."_wall_half_inverted", "moreblocks:stair_"..newname.."_wall_half_inverted")
+ minetest.register_alias(modname..":stair_"..origname.."_half", "moreblocks:stair_"..newname.."_half")
+ minetest.register_alias(modname..":stair_"..origname.."_half_inverted", "moreblocks:stair_"..newname.."_half_inverted")
+ minetest.register_alias(modname..":stair_"..origname.."_right_half", "moreblocks:stair_"..newname.."_right_half")
+ minetest.register_alias(modname..":stair_"..origname.."_right_half_inverted", "moreblocks:stair_"..newname.."_right_half_inverted")
+ minetest.register_alias(modname..":stair_"..origname.."_wall_half", "moreblocks:stair_"..newname.."_wall_half")
+ minetest.register_alias(modname..":stair_"..origname.."_wall_half_inverted", "moreblocks:stair_"..newname.."_wall_half_inverted")
+ minetest.register_alias(modname..":stair_"..origname.."_inner", "moreblocks:stair_"..newname.."_inner")
+ minetest.register_alias(modname..":stair_"..origname.."_inner_inverted", "moreblocks:stair_"..newname.."_inner_inverted")
+ minetest.register_alias(modname..":stair_"..origname.."_outer", "moreblocks:stair_"..newname.."_outer")
+ minetest.register_alias(modname..":stair_"..origname.."_outer_inverted", "moreblocks:stair_"..newname.."_outer_inverted")
+ minetest.register_alias(modname..":panel_"..origname.."_bottom", "moreblocks:panel_"..newname.."_bottom")
+ minetest.register_alias(modname..":panel_"..origname.."_top", "moreblocks:panel_"..newname.."_top")
+ minetest.register_alias(modname..":panel_"..origname.."_vertical", "moreblocks:panel_"..newname.."_vertical")
+ minetest.register_alias(modname..":micro_"..origname.."_bottom", "moreblocks:micro_"..newname.."_bottom")
+ minetest.register_alias(modname..":micro_"..origname.."_top", "moreblocks:micro_"..newname.."_top")
end
register_stairsplus_alias("stairsplus", "stone", "stone")
@@ -59,3 +60,4 @@ register_stairsplus_alias("moreblocks", "splitstonesquare", "split_stone_tile")
register_stairsplus_alias("moreblocks", "woodtile", "wood_tile")
register_stairsplus_alias("moreblocks", "woodtile_centered", "wood_tile_centered")
register_stairsplus_alias("moreblocks", "woodtile_full", "wood_tile_full")
+
diff --git a/stairsplus/conversion.lua b/stairsplus/conversion.lua
new file mode 100644
index 0000000..d3f7988
--- /dev/null
+++ b/stairsplus/conversion.lua
@@ -0,0 +1,132 @@
+-- Function to convert all stairs/slabs/etc nodes from
+-- inverted, wall, etc to regular + 6d facedir
+
+local dirs1 = {21, 20, 23, 22, 21}
+local dirs2 = {15, 8, 17, 6, 15}
+local dirs3 = {14, 11, 16, 5, 14}
+
+function stairsplus:register_6dfacedir_conversion(modname, material)
+ --print("Register stairsplus 6d facedir conversion")
+ --print('ABM for '..modname..' "'..material..'"')
+
+ local objects_list1 = {
+ modname..":slab_"..material.."_inverted",
+ modname..":slab_"..material.."_quarter_inverted",
+ modname..":slab_"..material.."_three_quarter_inverted",
+ modname..":stair_"..material.."_inverted",
+ modname..":stair_"..material.."_wall",
+ modname..":stair_"..material.."_wall_half",
+ modname..":stair_"..material.."_wall_half_inverted",
+ modname..":stair_"..material.."_half_inverted",
+ modname..":stair_"..material.."_right_half_inverted",
+ modname..":panel_"..material.."_vertical",
+ modname..":panel_"..material.."_top",
+ }
+
+ local objects_list2 = {
+ modname..":slab_"..material.."_wall",
+ modname..":slab_"..material.."_quarter_wall",
+ modname..":slab_"..material.."_three_quarter_wall",
+ modname..":stair_"..material.."_inner_inverted",
+ modname..":stair_"..material.."_outer_inverted",
+ modname..":micro_"..material.."_top"
+ }
+
+ for _, object in pairs(objects_list1) do
+ local flip_upside_down = false
+ local flip_to_wall = false
+
+ local dest_object = object
+
+ if string.find(dest_object, "_inverted") then
+ flip_upside_down = true
+ dest_object = string.gsub(dest_object, "_inverted", "")
+ end
+
+ if string.find(object, "_top") then
+ flip_upside_down = true
+ dest_object = string.gsub(dest_object, "_top", "")
+ end
+
+ if string.find(dest_object, "_wall") then
+ flip_to_wall = true
+ dest_object = string.gsub(dest_object, "_wall", "")
+ end
+
+ if string.find(dest_object, "_vertical") then
+ flip_to_wall = true
+ dest_object = string.gsub(dest_object, "_vertical", "")
+ end
+
+ if string.find(dest_object, "_half") and not string.find(dest_object, "_right_half") then
+ dest_object = string.gsub(dest_object, "_half", "_right_half")
+ elseif string.find(dest_object, "_right_half") then
+ dest_object = string.gsub(dest_object, "_right_half", "_half")
+ end
+
+ --print(" +---> convert "..object)
+ --print(" | to "..dest_object)
+
+ minetest.register_abm({
+ nodenames = {object},
+ interval = 1,
+ chance = 1,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ local fdir = node.param2 or 0
+
+ if flip_upside_down and not flip_to_wall then
+ nfdir = dirs1[fdir + 2]
+ elseif flip_to_wall and not flip_upside_down then
+ nfdir = dirs2[fdir + 1]
+ elseif flip_to_wall and flip_upside_down then
+ nfdir = dirs3[fdir + 2]
+ end
+ minetest.set_node(pos, {name = dest_object, param2 = nfdir})
+ end
+ })
+ end
+
+ for _, object in pairs(objects_list2) do
+ local flip_upside_down = false
+ local flip_to_wall = false
+
+ local dest_object = object
+
+ if string.find(dest_object, "_inverted") then
+ flip_upside_down = true
+ dest_object = string.gsub(dest_object, "_inverted", "")
+ end
+
+ if string.find(dest_object, "_top") then
+ flip_upside_down = true
+ dest_object = string.gsub(dest_object, "_top", "")
+ end
+
+ if string.find(dest_object, "_wall") then
+ flip_to_wall = true
+ dest_object = string.gsub(dest_object, "_wall", "")
+ end
+
+ --print(" +---> convert "..object)
+ --print(" | to "..dest_object)
+
+ minetest.register_abm({
+ nodenames = {object},
+ interval = 1,
+ chance = 1,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ local fdir = node.param2
+ local nfdir = 20
+
+ if flip_upside_down and not flip_to_wall then
+ nfdir = dirs1[fdir + 1]
+ elseif flip_to_wall and not flip_upside_down then
+ nfdir = dirs2[fdir + 2]
+
+ end
+ minetest.set_node(pos, {name = dest_object, param2 = nfdir})
+ end
+ })
+ end
+end
+
diff --git a/stairsplus/init.lua b/stairsplus/init.lua
new file mode 100644
index 0000000..cf2d0de
--- /dev/null
+++ b/stairsplus/init.lua
@@ -0,0 +1,45 @@
+
+-- Nodes will be called <modname>:{stair,slab,panel,micro}_<subname>
+
+local modpath = minetest.get_modpath("moreblocks").."/stairsplus"
+
+stairsplus = {}
+stairsplus.expect_infinite_stacks = false
+
+if not minetest.get_modpath("unified_inventory") and
+ minetest.setting_getbool("creative_mode") then
+ stairsplus.expect_infinite_stacks = true
+end
+
+function stairsplus:register_all(modname, subname, recipeitem, fields)
+ fields = fields or {}
+ fields.groups = fields.groups or {}
+ if not moreblocks.config.show_stairsplus_creative_inv then
+ fields.groups.not_in_creative_inventory = 1
+ end
+ self:register_stair(modname, subname, recipeitem, fields)
+ self:register_slab (modname, subname, recipeitem, fields)
+ self:register_panel(modname, subname, recipeitem, fields)
+ self:register_micro(modname, subname, recipeitem, fields)
+ self:register_6dfacedir_conversion(modname, subname)
+ circular_saw.known_nodes[recipeitem] = {modname, subname}
+end
+
+function register_stair_slab_panel_micro(modname, subname, recipeitem, groups, images, description, drop, light)
+ stairsplus:register_all(modname, subname, recipeitem, {
+ groups = groups,
+ tiles = images,
+ description = description,
+ drop = drop,
+ light_source = light
+ })
+end
+
+dofile(modpath.."/conversion.lua")
+dofile(modpath.."/stairs.lua")
+dofile(modpath.."/slabs.lua")
+dofile(modpath.."/panels.lua")
+dofile(modpath.."/microblocks.lua")
+dofile(modpath.."/aliases.lua")
+dofile(modpath.."/registrations.lua")
+
diff --git a/stairsplus/microblocks.lua b/stairsplus/microblocks.lua
index 30a95ea..6348bf6 100644
--- a/stairsplus/microblocks.lua
+++ b/stairsplus/microblocks.lua
@@ -1,142 +1,86 @@
-- Load translation library if intllib is installed
local S
-if (minetest.get_modpath("intllib")) then
- dofile(minetest.get_modpath("intllib").."/intllib.lua")
+if intllib then
S = intllib.Getter(minetest.get_current_modname())
- else
- S = function ( s ) return s end
+else
+ S = function(s) return s end
end
--- 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)
-
- minetest.register_node(":"..modname .. ":micro_" .. subname, {
- description = S("%s Microblock"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":micro_" .. drop,
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
+ return stairsplus:register_micro(modname, subname, recipeitem, {
groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, 0, 0, 0, 0.5},
- },
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":"..modname .. ":micro_" .. subname .. "_1", {
- description = S("%s Microblock"):format(S(description)),
- drawtype = "nodebox",
tiles = images,
+ description = description,
+ drop = drop,
light_source = light,
- drop = modname .. ":micro_" .. drop .. "_1",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, 0, 0, -0.4375, 0.5},
- },
sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
})
-
- minetest.register_node(":"..modname .. ":micro_" .. subname .. "_2", {
- description = S("%s Microblock"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":micro_" .. drop .. "_2",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, 0, 0, -0.375, 0.5},
+end
+
+function stairsplus:register_micro(modname, subname, recipeitem, fields)
+ local defs = {
+ [""] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, 0, 0, 0, 0.5},
+ },
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":"..modname .. ":micro_" .. subname .. "_4", {
- description = S("%s Microblock"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":micro_" .. drop .. "_4",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, 0, 0, -0.25, 0.5},
+ ["_1"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, 0, 0, -0.4375, 0.5},
+ },
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":"..modname .. ":micro_" .. subname .. "_12", {
- description = S("%s Microblock"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":micro_" .. drop .. "_12",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, 0, 0, 0.25, 0.5},
+ ["_2"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, 0, 0, -0.375, 0.5},
+ },
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":"..modname .. ":micro_" .. subname .. "_14", {
- description = S("%s Microblock"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":micro_" .. drop .. "_14",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- 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},
+ },
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":"..modname .. ":micro_" .. subname .. "_15", {
- description = S("%s Microblock"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":micro_" .. drop .. "_15",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, 0, 0, 0.4375, 0.5},
+ ["_12"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, 0, 0, 0.25, 0.5},
+ },
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
+ ["_14"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, 0, 0, 0.375, 0.5},
+ },
+ },
+ ["_15"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, 0, 0, 0.4375, 0.5},
+ },
+ }
+ }
+
+ local desc = S("%s Microblock"):format(fields.description)
+ for alternate, def in pairs(defs) do
+ def.drawtype = "nodebox"
+ def.paramtype = "light"
+ def.paramtype2 = "facedir"
+ def.on_place = minetest.rotate_node
+ for k, v in pairs(fields) do
+ def[k] = v
+ end
+ 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)
end
diff --git a/stairsplus/panels.lua b/stairsplus/panels.lua
index f074d54..efabd46 100644
--- a/stairsplus/panels.lua
+++ b/stairsplus/panels.lua
@@ -1,135 +1,87 @@
-- Load translation library if intllib is installed
local S
-if (minetest.get_modpath("intllib")) then
- dofile(minetest.get_modpath("intllib").."/intllib.lua")
+if intllib then
S = intllib.Getter(minetest.get_current_modname())
- else
- S = function ( s ) return s end
+else
+ S = function(s) return s end
end
--- 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)
-
- minetest.register_node(":" .. modname .. ":panel_" .. subname, {
- description = S("%s Panel"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":panel_" .. drop,
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
+ return stairsplus:register_panel(modname, subname, recipeitem, {
groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, 0, 0.5, 0, 0.5},
- },
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":" .. modname .. ":panel_" .. subname .. "_1", {
- description = S("%s Panel"):format(S(description)),
- drawtype = "nodebox",
tiles = images,
+ description = description,
+ drop = drop,
light_source = light,
- drop = modname .. ":panel_" .. drop .. "_1",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, 0, 0.5, -0.4375, 0.5},
- },
- on_place = stairsplus_rotate_and_place
+ sounds = default.node_sound_stone_defaults(),
})
-
- minetest.register_node(":" .. modname .. ":panel_" .. subname .. "_2", {
- description = S("%s Panel"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":panel_" .. drop .. "_2",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, 0, 0.5, -0.375, 0.5},
+end
+
+
+function stairsplus:register_panel(modname, subname, recipeitem, fields)
+ local defs = {
+ [""] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, 0, 0.5, 0, 0.5},
+ },
},
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":" .. modname .. ":panel_" .. subname .. "_4", {
- description = S("%s Panel"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":panel_" .. drop .. "_4",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, 0, 0.5, -0.25, 0.5},
+ ["_1"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, 0, 0.5, -0.4375, 0.5},
+ },
},
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":" .. modname .. ":panel_" .. subname .. "_12", {
- description = S("%s Panel"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":panel_" .. drop .. "_12",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, 0, 0.5, 0.25, 0.5},
+ ["_2"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, 0, 0.5, -0.375, 0.5},
+ },
},
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":" .. modname .. ":panel_" .. subname .. "_14", {
- description = S("%s Panel"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":panel_" .. drop .. "_14",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- 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},
+ },
},
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":" .. modname .. ":panel_" .. subname .. "_15", {
- description = S("%s Panel"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":panel_" .. drop .. "_15",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, 0, 0.5, 0.4375, 0.5},
+ ["_12"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, 0, 0.5, 0.25, 0.5},
+ },
},
- on_place = stairsplus_rotate_and_place
- })
+ ["_14"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, 0, 0.5, 0.375, 0.5},
+ },
+ },
+ ["_15"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, 0, 0.5, 0.4375, 0.5},
+ },
+ }
+ }
+
+ local desc = S("%s Panel"):format(fields.description)
+ for alternate, def in pairs(defs) do
+ def.drawtype = "nodebox"
+ def.paramtype = "light"
+ def.paramtype2 = "facedir"
+ def.on_place = minetest.rotate_node
+ for k, v in pairs(fields) do
+ def[k] = v
+ end
+ def.description = desc
+ 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)
end
diff --git a/stairsplus/registrations.lua b/stairsplus/registrations.lua
new file mode 100644
index 0000000..6e44ee1
--- /dev/null
+++ b/stairsplus/registrations.lua
@@ -0,0 +1,45 @@
+-- Default stairs/slabs/panels/microblocks
+
+local default_nodes = {
+ "stone",
+ "cobble",
+ "mossycobble",
+ "brick",
+ "sandstone",
+ "steelblock",
+ "goldblock",
+ "copperblock",
+ "bronzeblock",
+ "diamondblock",
+ "desert_stone",
+ "glass",
+ "tree",
+ "wood",
+ "jungletree",
+ "junglewood",
+ "obsidian",
+ "obsidian_glass",
+ "stonebrick",
+ "desert_stonebrick",
+ "sandstonebrick",
+}
+
+for _, name in pairs(default_nodes) do
+ local nodename = "default:"..name
+ local ndef = minetest.registered_nodes[nodename]
+ local groups = {}
+ for k, v in pairs(ndef.groups) do groups[k] = v end
+ local drop
+ if type(ndef.drop) == "string" then
+ drop = ndef.drop:sub(9)
+ end
+ stairsplus:register_all("moreblocks", name, nodename, {
+ description = ndef.description,
+ drop = drop,
+ groups = groups,
+ sounds = ndef.sounds,
+ tiles = ndef.tiles,
+ sunlight_propagates = ndef.sunlight_propagates,
+ })
+end
+
diff --git a/stairsplus/slabs.lua b/stairsplus/slabs.lua
index 687dbee..a606392 100644
--- a/stairsplus/slabs.lua
+++ b/stairsplus/slabs.lua
@@ -1,170 +1,96 @@
-- Load translation library if intllib is installed
local S
-if (minetest.get_modpath("intllib")) then
- dofile(minetest.get_modpath("intllib").."/intllib.lua")
+if intllib then
S = intllib.Getter(minetest.get_current_modname())
- else
- S = function ( s ) return s end
+else
+ S = function(s) return s end
end
--- 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)
-
- minetest.register_node(":" .. modname .. ":slab_" .. subname, {
- description = S("%s Slab"):format(S(description)),
- drawtype = "nodebox",
+ return stairsplus:register_slab(modname, subname, recipeitem, {
+ groups = groups,
tiles = images,
+ description = description,
+ drop = drop,
light_source = light,
- drop = modname .. ":slab_" .. drop,
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
- },
sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
})
+end
- minetest.register_node(":stairs:slab_" .. subname, {
- description = S("%s Slab"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- drop = modname .. ":slab_" .. drop,
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
+function stairsplus:register_slab(modname, subname, recipeitem, fields)
+ local defs = {
+ [""] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
+ },
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":"..modname .. ":slab_" .. subname .. "_quarter", {
- description = S("%s Slab"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":slab_" .. drop .. "_quarter",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, -0.5, 0.5, -0.25, 0.5},
+ ["_quarter"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, -0.5, 0.5, -0.25, 0.5},
+ },
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":"..modname .. ":slab_" .. subname .. "_three_quarter", {
- description = S("%s Slab"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":slab_" .. drop .. "_three_quarter",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, -0.5, 0.5, 0.25, 0.5},
+ ["_three_quarter"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, -0.5, 0.5, 0.25, 0.5},
+ },
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":"..modname .. ":slab_" .. subname .. "_1", {
- description = S("%s Slab"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":slab_" .. drop .. "_1",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
+ ["_1"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
+ },
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":"..modname .. ":slab_" .. subname .. "_2", {
- description = S("%s Slab"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":slab_" .. drop .. "_2",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
+ ["_2"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
+ },
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":"..modname .. ":slab_" .. subname .. "_14", {
- description = S("%s Slab"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":slab_" .. drop .. "_14",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, -0.5, 0.5, 0.375, 0.5},
+ ["_14"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, -0.5, 0.5, 0.375, 0.5},
+ },
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":"..modname .. ":slab_" .. subname .. "_15", {
- description = S("%s Slab"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":slab_" .. drop .. "_15",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, -0.5, 0.5, 0.4375, 0.5},
+ ["_15"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, -0.5, 0.5, 0.4375, 0.5},
+ },
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
+ }
+ local desc = S("%s Slab"):format(fields.description)
+ for alternate, def in pairs(defs) do
+ def.drawtype = "nodebox"
+ def.paramtype = "light"
+ def.paramtype2 = "facedir"
+ def.on_place = minetest.rotate_node
+ for k, v in pairs(fields) do
+ def[k] = v
+ end
+ def.description = desc
+ 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)
- -- Unregister default recipes, optional, see _config.txt
+ -- Unregister default recipes, optional, see config.lua
-if allow_stair_slab_crafting == false
-then
- minetest.register_craft({
- output = "moreblocks:nothing 1",
- recipe = {
- {recipeitem, recipeitem, recipeitem},
- },
- })
-end
+ if not moreblocks.config.allow_stair_slab_crafting then
+ minetest.register_craft({
+ output = "moreblocks:nothing 1",
+ recipe = {
+ {recipeitem, recipeitem, recipeitem},
+ },
+ })
+ end
end
diff --git a/stairsplus/stairs.lua b/stairsplus/stairs.lua
index b11fef9..12b7847 100644
--- a/stairsplus/stairs.lua
+++ b/stairsplus/stairs.lua
@@ -1,240 +1,149 @@
-- Load translation library if intllib is installed
local S
-if (minetest.get_modpath("intllib")) then
- dofile(minetest.get_modpath("intllib").."/intllib.lua")
+if intllib then
S = intllib.Getter(minetest.get_current_modname())
- else
- S = function ( s ) return s end
+else
+ S = function(s) return s end
end
-- Node will be called <modname>:stair_<subname>
function register_stair(modname, subname, recipeitem, groups, images, description, drop, light)
-
- minetest.register_node(":" .. modname .. ":stair_" .. subname, {
- description = S("%s Stairs"):format(S(description)),
- drawtype = "nodebox",
+ return stairsplus:register_stair(modname, subname, recipeitem, {
+ groups = groups,
tiles = images,
+ description = description,
+ drop = drop,
light_source = light,
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
- {-0.5, 0, 0, 0.5, 0.5, 0.5},
- },
- },
sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
})
+end
- minetest.register_node(":stairs:stair_" .. subname, {
- description = S("%s Stairs"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = {cracky=3, not_in_creative_inventory=1},
- node_box = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
- {-0.5, 0, 0, 0.5, 0.5, 0.5},
+function stairsplus:register_stair(modname, subname, recipeitem, fields)
+ local defs = {
+ [""] = {
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
+ {-0.5, 0, 0, 0.5, 0.5, 0.5},
+ },
},
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":" .. modname .. ":stair_" .. subname .. "_half", {
- description = S("%s Stairs"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0, 0, 0.5},
- {-0.5, 0, 0, 0, 0.5, 0.5},
+ ["_half"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.5, -0.5, -0.5, 0, 0, 0.5},
+ {-0.5, 0, 0, 0, 0.5, 0.5},
+ },
},
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":"..modname .. ":stair_" .. subname .. "_right_half", {
- description = S("%s Stairs"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {
- {0, -0.5, -0.5, 0.5, 0, 0.5},
- {0, 0, 0, 0.5, 0.5, 0.5},
+ ["_right_half" ]= {
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {0, -0.5, -0.5, 0.5, 0, 0.5},
+ {0, 0, 0, 0.5, 0.5, 0.5},
+ },
},
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":"..modname .. ":stair_" .. subname .. "_inner", {
- description = S("%s Stairs"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":stair_" .. drop .. "_inner",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
- {-0.5, 0, 0, 0.5, 0.5, 0.5},
- {-0.5, 0, -0.5, 0, 0.5, 0},
+ ["_inner"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
+ {-0.5, 0, 0, 0.5, 0.5, 0.5},
+ {-0.5, 0, -0.5, 0, 0.5, 0},
+ },
},
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":"..modname .. ":stair_" .. subname .. "_outer", {
- description = S("%s Stairs"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- drop = modname .. ":stair_" .. drop .. "_outer",
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
- {-0.5, 0, 0, 0, 0.5, 0.5},
+ ["_outer"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
+ {-0.5, 0, 0, 0, 0.5, 0.5},
+ },
},
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":" .. modname .. ":stair_" .. subname .. "_alt", {
- description = S("%s Stairs"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, 0, 0},
- {-0.5, 0, 0, 0.5, 0.5, 0.5},
+ ["_alt"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.5, -0.5, -0.5, 0.5, 0, 0},
+ {-0.5, 0, 0, 0.5, 0.5, 0.5},
+ },
},
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":" .. modname .. ":stair_" .. subname .. "_alt_1", {
- description = S("%s Stairs"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {
- {-0.5, -0.0625, -0.5, 0.5, 0, 0},
- {-0.5, 0.4375, 0, 0.5, 0.5, 0.5},
+ ["_alt_1"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.5, -0.0625, -0.5, 0.5, 0, 0},
+ {-0.5, 0.4375, 0, 0.5, 0.5, 0.5},
+ },
},
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":" .. modname .. ":stair_" .. subname .. "_alt_2", {
- description = S("%s Stairs"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- 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"] = {
+ 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},
+ },
},
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
-
- minetest.register_node(":" .. modname .. ":stair_" .. subname .. "_alt_4", {
- description = S("%s Stairs"):format(S(description)),
- drawtype = "nodebox",
- tiles = images,
- light_source = light,
- paramtype = "light",
- paramtype2 = "facedir",
- sunlight_propagates = true,
- groups = groups,
- node_box = {
- type = "fixed",
- fixed = {
- {-0.5, -0.25, -0.5, 0.5, 0, 0},
- {-0.5, 0.25, 0, 0.5, 0.5, 0.5},
+ ["_alt_4"] = {
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.5, -0.25, -0.5, 0.5, 0, 0},
+ {-0.5, 0.25, 0, 0.5, 0.5, 0.5},
+ },
},
},
- sounds = default.node_sound_stone_defaults(),
- on_place = stairsplus_rotate_and_place
- })
+ }
- -- Unregister default recipes, optional, see _config.txt
+ local desc = S("%s Stairs"):format(fields.description)
+ for alternate, def in pairs(defs) do
+ def.drawtype = "nodebox"
+ def.paramtype = "light"
+ def.paramtype2 = "facedir"
+ def.on_place = minetest.rotate_node
+ for k, v in pairs(fields) do
+ def[k] = v
+ end
+ def.description = desc
+ 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)
-if allow_stair_slab_crafting == false
-then
- minetest.register_craft({
- output = "moreblocks:nothing 1",
- recipe = {
- {recipeitem, "", ""},
- {recipeitem, recipeitem, ""},
- {recipeitem, recipeitem, recipeitem},
- },
- })
- minetest.register_craft({
- output = "moreblocks:nothing 1",
- recipe = {
- {"", "", recipeitem},
- {"", recipeitem, recipeitem},
- {recipeitem, recipeitem, recipeitem},
- },
- })
-end
+ -- Unregister default recipes, optional, see config.lua
+
+ if not moreblocks.config.allow_stair_slab_crafting then
+ minetest.register_craft({
+ output = "moreblocks:nothing 1",
+ recipe = {
+ {recipeitem, "", ""},
+ {recipeitem, recipeitem, ""},
+ {recipeitem, recipeitem, recipeitem},
+ },
+ })
+
+ minetest.register_craft({
+ output = "moreblocks:nothing 1",
+ recipe = {
+ {"", "", recipeitem},
+ {"", recipeitem, recipeitem},
+ {recipeitem, recipeitem, recipeitem},
+ },
+ })
+ end
end