From 1237bc3a4b3c6f435059d669345446fa44768f32 Mon Sep 17 00:00:00 2001 From: PilzAdam Date: Mon, 15 Dec 2014 22:12:21 +0100 Subject: [PATCH] Don't override param2 bits that are not used for rotation in screwdriver --- mods/screwdriver/init.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mods/screwdriver/init.lua b/mods/screwdriver/init.lua index 49ea6156..6e3fe816 100644 --- a/mods/screwdriver/init.lua +++ b/mods/screwdriver/init.lua @@ -37,16 +37,18 @@ local function screwdriver_handler(itemstack, user, pointed_thing, mode) end -- Set param2 - local n = node.param2 - local axisdir = math.floor(n / 4) - local rotation = n - axisdir * 4 + local rotationPart = node.param2 % 32 -- get first 4 bits + local preservePart = node.param2 - rotationPart + + local axisdir = math.floor(rotationPart / 4) + local rotation = rotationPart - axisdir * 4 if mode == ROTATE_FACE then - n = axisdir * 4 + nextrange(rotation, 3) + rotationPart = axisdir * 4 + nextrange(rotation, 3) elseif mode == ROTATE_AXIS then - n = nextrange(axisdir, 5) * 4 + rotationPart = nextrange(axisdir, 5) * 4 end - node.param2 = n + node.param2 = preservePart + rotationPart minetest.swap_node(pos, node) if not minetest.setting_getbool("creative_mode") then