From 9c99be0d08fbf5fbe8777344721936574b042e5d Mon Sep 17 00:00:00 2001 From: VitaliyShar <111154840+VitaliyShar@users.noreply.github.com> Date: Sat, 13 Aug 2022 20:39:48 +0300 Subject: [PATCH] Update init.lua --- mods/stairs/init.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mods/stairs/init.lua b/mods/stairs/init.lua index 7157d8f9..7f702ecd 100644 --- a/mods/stairs/init.lua +++ b/mods/stairs/init.lua @@ -25,16 +25,18 @@ minetest.register_alias("stairs:slab_pinewood", "stairs:slab_pine_wood") local replace = minetest.settings:get_bool("enable_stairs_replace_abm") local function rotate_and_place(itemstack, placer, pointed_thing) - local p0 = pointed_thing.under - local p1 = pointed_thing.above + local pUnder = pointed_thing.under + local pAbove = pointed_thing.above local param2 = 0 if placer then local placer_pos = placer:get_pos() if placer_pos then - local vec = vector.subtract(p1, placer_pos) - param2 = minetest.dir_to_facedir(vec) - if math.abs(vec.z) <= 0.5 and math.abs(vec.x) <= 0.5 and vec.y < 0 and p0.y == p1.y then + local vecdiff = vector.subtract(pAbove, placer_pos) + param2 = minetest.dir_to_facedir(vecdiff) + -- The player places a node on the side face of the node he is standing on + if math.abs(vecdiff.z) <= 0.5 and math.abs(vecdiff.x) <= 0.5 and vecdiff.y < 0 and pUnder.y == pAbove.y then + -- reverse node direction param2 = (param2 + 2) % 4 end end @@ -42,7 +44,7 @@ local function rotate_and_place(itemstack, placer, pointed_thing) local finepos = minetest.pointed_thing_to_face_pos(placer, pointed_thing) local fpos = finepos.y % 1 - if p0.y - 1 == p1.y or (fpos > 0 and fpos < 0.5) + if pUnder.y - 1 == pAbove.y or (fpos > 0 and fpos < 0.5) or (fpos < -0.5 and fpos > -0.999999999) then param2 = param2 + 20 if param2 == 21 then