diff options
Diffstat (limited to 'moreblocks/stairsplus')
-rw-r--r-- | moreblocks/stairsplus/registrations.lua | 119 | ||||
-rw-r--r-- | moreblocks/stairsplus/slabs.lua | 31 | ||||
-rw-r--r-- | moreblocks/stairsplus/stairs.lua | 4 |
3 files changed, 81 insertions, 73 deletions
diff --git a/moreblocks/stairsplus/registrations.lua b/moreblocks/stairsplus/registrations.lua index 7c5ad50..1e86954 100644 --- a/moreblocks/stairsplus/registrations.lua +++ b/moreblocks/stairsplus/registrations.lua @@ -5,6 +5,7 @@ Copyright (c) 2011-2017 Hugo Locurcio and contributors. Licensed under the zlib license. See LICENSE.md for more information. --]] +-- default registrations local default_nodes = { -- Default stairs/slabs/panels/microblocks: "stone", "stone_block", @@ -48,73 +49,81 @@ local default_nodes = { -- Default stairs/slabs/panels/microblocks: "desert_sandstone_block", "sandstone_block", "coral_skeleton", - "farming:straw" } for _, name in pairs(default_nodes) do - local nodename = "default:"..name - local a,b = string.find(name, ":") - if b then - nodename = name - name = string.sub(name, b+1) + local mod = "default" + local nodename = mod .. ":" .. name + local ndef = table.copy(minetest.registered_nodes[nodename]) + ndef.sunlight_propagates = true + + -- Stone and desert_stone drop cobble and desert_cobble respectively. + if type(ndef.drop) == "string" then + ndef.drop = ndef.drop:gsub(".+:", "") end - local ndef = minetest.registered_nodes[nodename] - if ndef then - local drop - if type(ndef.drop) == "string" then - drop = ndef.drop:sub((b or 8)+1) - end - local tiles = ndef.tiles - if #ndef.tiles > 1 and ndef.drawtype:find("glass") then - tiles = { ndef.tiles[1] } - end + -- Use the primary tile for all sides of cut glasslike nodes and disregard paramtype2. + if #ndef.tiles > 1 and ndef.drawtype and ndef.drawtype:find("glass") then + ndef.tiles = {ndef.tiles[1]} + ndef.paramtype2 = nil + end - stairsplus:register_all("moreblocks", name, nodename, { - description = ndef.description, - drop = drop, - groups = ndef.groups, - sounds = ndef.sounds, - tiles = tiles, - sunlight_propagates = true, - light_source = ndef.light_source - }) + mod = "moreblocks" + stairsplus:register_all(mod, name, nodename, ndef) + minetest.register_alias_force("stairs:stair_" .. name, mod .. ":stair_" .. name) + minetest.register_alias_force("stairs:slab_" .. name, mod .. ":slab_" .. name) +end + +-- farming registrations +if minetest.get_modpath("farming") then + local farming_nodes = {"straw"} + for _, name in pairs(farming_nodes) do + local mod = "farming" + local nodename = mod .. ":" .. name + local ndef = table.copy(minetest.registered_nodes[nodename]) + ndef.sunlight_propagates = true + + mod = "moreblocks" + stairsplus:register_all(mod, name, nodename, ndef) + minetest.register_alias_force("stairs:stair_" .. name, mod .. ":stair_" .. name) + minetest.register_alias_force("stairs:slab_" .. name, mod .. ":slab_" .. name) end end -- wool registrations - if minetest.get_modpath("wool") then + local dyes = {"white", "grey", "black", "red", "yellow", "green", "cyan", + "blue", "magenta", "orange", "violet", "brown", "pink", + "dark_grey", "dark_green"} + for _, name in pairs(dyes) do + local mod = "wool" + local nodename = mod .. ":" .. name + local ndef = table.copy(minetest.registered_nodes[nodename]) + ndef.sunlight_propagates = true - local colorlist = { - {"white", "White Wool"}, - {"grey", "Grey Wool"}, - {"black", "Black Wool"}, - {"red", "Red Wool"}, - {"yellow", "Yellow Wool"}, - {"green", "Green Wool"}, - {"cyan", "Cyan Wool"}, - {"blue", "Blue Wool"}, - {"magenta", "Magenta Wool"}, - {"orange", "Orange Wool"}, - {"violet", "Violet Wool"}, - {"brown", "Brown Wool"}, - {"pink", "Pink Wool"}, - {"dark_grey", "Dark Grey Wool"}, - {"dark_green", "Dark Green Wool"}, - } + -- Prevent dye+cut wool recipy from creating a full wool block. + ndef.groups.wool = nil - for i in ipairs(colorlist) do - local color = colorlist[i][1] - local colordesc = colorlist[i][2] - - stairsplus:register_all("wool", color, "wool:"..color, { - description = colordesc, - tiles = {"wool_"..color..".png"}, - groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3, - flammable=3,wool=1,not_in_creative_inventory=1}, - sounds = default.node_sound_defaults(), - sunlight_propagates = true, - }) + stairsplus:register_all(mod, name, nodename, ndef) end end + +-- Alias cuts of split_stone_tile_alt which was renamed checker_stone_tile. +stairsplus:register_alias_all("moreblocks", "split_stone_tile_alt", "moreblocks", "checker_stone_tile") + +-- The following LBM is necessary because the name stair_split_stone_tile_alt +-- conflicts with another node and so the alias for that specific node gets +-- ignored. +minetest.register_lbm({ + name = "moreblocks:fix_split_stone_tile_alt_name_collision", + nodenames = {"moreblocks:stair_split_stone_tile_alt"}, + action = function(pos, node) + minetest.set_node(pos, { + name = "moreblocks:stair_checker_stone_tile", + param2 = minetest.get_node(pos).param2 + + }) + minetest.log('action', "LBM replaced " .. node.name .. + " at " .. minetest.pos_to_string(pos)) + end, +}) diff --git a/moreblocks/stairsplus/slabs.lua b/moreblocks/stairsplus/slabs.lua index ea9dbc5..de7f031 100644 --- a/moreblocks/stairsplus/slabs.lua +++ b/moreblocks/stairsplus/slabs.lua @@ -66,29 +66,24 @@ function stairsplus:register_slab(modname, subname, recipeitem, fields) local defs = stairsplus.copytable(slabs_defs) local desc_base = S("%s Slab"):format(fields.description) for alternate, shape in pairs(defs) do - local def = {} - + for k, v in pairs(fields) do + def[k] = v + end if type(shape) ~= "table" then - def = { - node_box = { + def.node_box = { type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, (shape/16)-0.5, 0.5}, - }, - description = ("%s (%d/16)"):format(desc_base, shape) - } + } + def.description = ("%s (%d/16)"):format(desc_base, shape) else - def = { - node_box = { + def.node_box = { type = "fixed", fixed = shape, - }, - description = desc_base - } - end - - for k, v in pairs(fields) do - def[k] = v + } + local desc_x = alternate:gsub("_", " ") + desc_x = desc_x:gsub("(%a)(%S*)", function(a, b) return a:upper() .. b end) + def.description = desc_base .. desc_x end def.drawtype = "nodebox" @@ -96,12 +91,14 @@ function stairsplus:register_slab(modname, subname, recipeitem, fields) def.paramtype2 = def.paramtype2 or "facedir" def.on_place = minetest.rotate_node def.groups = stairsplus:prepare_groups(fields.groups) + if alternate == "" then + def.groups.slab = 1 + end if fields.drop and not (type(fields.drop) == "table") 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) circular_saw.known_nodes[recipeitem] = {modname, subname} diff --git a/moreblocks/stairsplus/stairs.lua b/moreblocks/stairsplus/stairs.lua index 0291e7d..815f7ac 100644 --- a/moreblocks/stairsplus/stairs.lua +++ b/moreblocks/stairsplus/stairs.lua @@ -136,12 +136,14 @@ function stairsplus:register_stair(modname, subname, recipeitem, fields) def.on_place = minetest.rotate_node def.description = desc def.groups = stairsplus:prepare_groups(fields.groups) + if alternate == "" then + def.groups.stair = 1 + end if fields.drop and not (type(fields.drop) == "table") 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) circular_saw.known_nodes[recipeitem] = {modname, subname} |