From ad2c11ed9d10080fed308bc8b12c233a3e99b0e5 Mon Sep 17 00:00:00 2001 From: Athozus Date: Sun, 14 Apr 2024 03:13:19 +0200 Subject: [PATCH] Fix cable plate placing on several-blocks nodes (#358) Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> --- technic/machines/register/cables.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/technic/machines/register/cables.lua b/technic/machines/register/cables.lua index cdf074a4..c2057460 100644 --- a/technic/machines/register/cables.lua +++ b/technic/machines/register/cables.lua @@ -96,13 +96,20 @@ function technic.register_cable_plate(nodename, data) def.node_box["connect_"..notconnects[i]] = nil if i == 1 then def.on_place = function(itemstack, placer, pointed_thing) - local pointed_thing_diff = vector.subtract(pointed_thing.above, pointed_thing.under) + local count = 0 + for axis in pairs(xyz) do + count = count + (pointed_thing.under[axis] == pointed_thing.above[axis] and 0 or 1) + if count > 1 then + return itemstack + end + end + local pointed_thing_diff = vector.direction(pointed_thing.under, pointed_thing.above) local index = pointed_thing_diff.x + (pointed_thing_diff.y*2) + (pointed_thing_diff.z*3) local num = index < 0 and -index + 3 or index local crtl = placer:get_player_control() if (crtl.aux1 or crtl.sneak) and not (crtl.aux1 and crtl.sneak) and index ~= 0 then local fine_pointed = minetest.pointed_thing_to_face_pos(placer, pointed_thing) - fine_pointed = vector.subtract(fine_pointed, pointed_thing.above) + fine_pointed = vector.direction(pointed_thing.above,fine_pointed) fine_pointed[xyz[index < 0 and -index or index]] = nil local key_a, a = next(fine_pointed) local key_b, b = next(fine_pointed, key_a)