From 562a9d6d98a831e86f57c5e643bd28211b4986c4 Mon Sep 17 00:00:00 2001 From: codiac Date: Fri, 3 Nov 2023 17:48:59 +1000 Subject: [PATCH] Convert stairs to nodebox --- mods/ITEMS/mcl_stairs/api.lua | 18 +++++++++++++++--- mods/ITEMS/mcl_stairs/cornerstair.lua | 23 +---------------------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/mods/ITEMS/mcl_stairs/api.lua b/mods/ITEMS/mcl_stairs/api.lua index 390461c6c..f63d8daa1 100644 --- a/mods/ITEMS/mcl_stairs/api.lua +++ b/mods/ITEMS/mcl_stairs/api.lua @@ -93,17 +93,29 @@ function mcl_stairs.register_stair(subname, recipeitem, groups, images, descript groups.stair = 1 groups.building_block = 1 + local image_table = {} + for i, image in ipairs(images) do + image_table[i] = type(image) == "string" and { name = image } or table.copy(image) + image_table[i].align_style = "world" + end + minetest.register_node(":mcl_stairs:stair_" .. subname, { description = description, _doc_items_longdesc = S("Stairs are useful to reach higher places by walking over them; jumping is not required. Placing stairs in a corner pattern will create corner stairs. Stairs placed on the ceiling or at the upper half of the side of a block will be placed upside down."), - drawtype = "mesh", - mesh = "stairs_stair.obj", - tiles = images, + drawtype = "nodebox", + tiles = image_table, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, groups = groups, sounds = sounds, + 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}, + }, + }, selection_box = { type = "fixed", fixed = { diff --git a/mods/ITEMS/mcl_stairs/cornerstair.lua b/mods/ITEMS/mcl_stairs/cornerstair.lua index 8acaac5d8..03f8aacca 100644 --- a/mods/ITEMS/mcl_stairs/cornerstair.lua +++ b/mods/ITEMS/mcl_stairs/cornerstair.lua @@ -207,28 +207,7 @@ function mcl_stairs.cornerstair.add(name, stairtiles) local node_def = minetest.registered_nodes[name] local outer_tiles local inner_tiles - if stairtiles == "woodlike" then - outer_tiles = table.copy(node_def.tiles) - inner_tiles = table.copy(node_def.tiles) - for i=2,6 do - if outer_tiles[i] == nil then - outer_tiles[i] = outer_tiles[i-1] - end - if inner_tiles[i] == nil then - inner_tiles[i] = inner_tiles[i-1] - end - end - local t = node_def.tiles[1] - outer_tiles[1] = t.."^("..t.."^[transformR90^mcl_stairs_turntexture.png^[makealpha:255,0,255)" - outer_tiles[2] = t.."^("..t.."^mcl_stairs_turntexture.png^[transformR270^[makealpha:255,0,255)" - outer_tiles[3] = t - inner_tiles[1] = t.."^("..t.."^[transformR90^(mcl_stairs_turntexture.png^[transformR180)^[makealpha:255,0,255)" - inner_tiles[2] = t.."^("..t.."^[transformR270^(mcl_stairs_turntexture.png^[transformR90)^[makealpha:255,0,255)" - inner_tiles[3] = t - elseif stairtiles == nil or stairtiles == "default" then - outer_tiles = node_def.tiles - inner_tiles = node_def.tiles - else + if stairtiles ~= nil and stairtiles ~= "default" and stairtiles ~= "woodlike" then outer_tiles = stairtiles[1] inner_tiles = stairtiles[2] end