Skip to content

Commit

Permalink
fix #17
Browse files Browse the repository at this point in the history
  • Loading branch information
wsor4035 committed May 3, 2022
1 parent fe1b9a1 commit 2e3a826
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
8 changes: 8 additions & 0 deletions building_blocks/node_stairs.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
local S = minetest.get_translator("building_blocks")
local stairs_compat

if minetest.get_modpath("stairs") and not minetest.get_modpath("moreblocks") then
stairs_compat = dofile(minetest.get_modpath("building_blocks") .. "/stairs_compat.lua")
end

local function building_blocks_stairs(nodename, def)
minetest.register_node(nodename, def)
Expand All @@ -11,6 +16,9 @@ local function building_blocks_stairs(nodename, def)
minetest.register_alias("stairs:stair_inner_" .. name, mod .. ":stair_" .. name .. "_inner")
minetest.register_alias("stairs:stair_outer_" .. name, mod .. ":stair_" .. name .. "_outer")
end
if stairs_compat then
stairs_compat(nodename, def)
end
end

building_blocks_stairs("building_blocks:grate", {
Expand Down
54 changes: 54 additions & 0 deletions building_blocks/stairs_compat.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
local stairtable = {
{
"slab",
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
{
"stair",
{
{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
{-0.5, 0.0, 0.0, 0.5, 0.5, 0.5},
},
},
{
"stair_inner",
{
{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
{-0.5, 0.0, 0.0, 0.5, 0.5, 0.5},
{-0.5, 0.0, -0.5, 0.0, 0.5, 0.0},
},
},
{
"stair_outer",
{
{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
{-0.5, 0.0, 0.0, 0.0, 0.5, 0.5},
},
},
}

local function register(name, def)
for _, sdef in pairs(stairtable) do
local split = name:split(":")
local ndef = table.copy(def)
local item_name = ":" .. sdef[1] .. "_" .. split[2]

ndef.description = def.description .. " " .. string.gsub(sdef[1], "_", " ")
ndef.paramtype, ndef.paramtype2 = "light", "facedir"
ndef.drawtype = "nodebox"
ndef.node_box = {
type = "fixed",
fixed = sdef[2],
}

minetest.register_node(split[1] .. item_name, ndef)
minetest.register_alias("stairs" .. item_name, split[1] .. item_name)
end
end

minetest.log(
"action",
"[building_blocks]: depreciated legacy support for stairs loaded, please use moreblocks for stair support"
)

return register

0 comments on commit 2e3a826

Please sign in to comment.