diff --git a/homedecor_seating/armchairs.lua b/homedecor_seating/armchairs.lua index 2c7d1c3b..6de86d62 100644 --- a/homedecor_seating/armchairs.lua +++ b/homedecor_seating/armchairs.lua @@ -35,6 +35,7 @@ minetest.register_node(":lrfurn:armchair", { return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1) end, on_destruct = lrfurn.on_seat_destruct, + on_movenode = lrfurn.on_seat_movenode, }) homedecor.register("armchair", { @@ -62,6 +63,7 @@ homedecor.register("armchair", { return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1) end, on_destruct = lrfurn.on_seat_destruct, + on_movenode = lrfurn.on_seat_movenode, }) -- crafts diff --git a/homedecor_seating/init.lua b/homedecor_seating/init.lua index c4c0bf9e..f787a470 100644 --- a/homedecor_seating/init.lua +++ b/homedecor_seating/init.lua @@ -221,6 +221,20 @@ function lrfurn.on_seat_destruct(pos) --called when a seat is destroyed end end +function lrfurn.on_seat_movenode(from_pos, to_pos) + for name, seatpos in pairs(seated_cache) do + if seatpos == minetest.hash_node_position(from_pos) then + local player = minetest.get_player_by_name(name) + if player then + local attached_to = player:get_attach() + if attached_to then --check, a stupid clearobjects might have been called, etc + attached_to:set_pos(to_pos) + end + end + end + end +end + --if the player gets killed in the seat, handle it minetest.register_on_dieplayer(function(player) if seated_cache[player:get_player_name()] then diff --git a/homedecor_seating/longsofas.lua b/homedecor_seating/longsofas.lua index 4f1c7c96..5d22a69e 100644 --- a/homedecor_seating/longsofas.lua +++ b/homedecor_seating/longsofas.lua @@ -49,6 +49,7 @@ minetest.register_node(":lrfurn:longsofa", { return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 3) end, on_destruct = lrfurn.on_seat_destruct, + on_movenode = lrfurn.on_seat_movenode, }) minetest.register_craft({ diff --git a/homedecor_seating/misc.lua b/homedecor_seating/misc.lua index 386de67c..4ceb5865 100644 --- a/homedecor_seating/misc.lua +++ b/homedecor_seating/misc.lua @@ -24,6 +24,7 @@ homedecor.register("deckchair", { return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1) end, on_destruct = lrfurn.on_seat_destruct, + on_movenode = lrfurn.on_seat_movenode, }) minetest.register_alias("homedecor:deckchair_foot", "homedecor:deckchair") @@ -45,6 +46,7 @@ homedecor.register("deckchair_striped_blue", { return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1) end, on_destruct = lrfurn.on_seat_destruct, + on_movenode = lrfurn.on_seat_movenode, }) homedecor.register("simple_bench", { @@ -66,6 +68,7 @@ homedecor.register("simple_bench", { return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1) end, on_destruct = lrfurn.on_seat_destruct, + on_movenode = lrfurn.on_seat_movenode, }) local bl1_sbox = { @@ -159,6 +162,7 @@ homedecor.register("kitchen_chair_wood", { return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1) end, on_destruct = lrfurn.on_seat_destruct, + on_movenode = lrfurn.on_seat_movenode, }) homedecor.register("kitchen_chair_padded", { @@ -186,6 +190,7 @@ homedecor.register("kitchen_chair_padded", { return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1) end, on_destruct = lrfurn.on_seat_destruct, + on_movenode = lrfurn.on_seat_movenode, }) local ofchairs_sbox = { @@ -226,6 +231,7 @@ for _, c in pairs(chairs) do return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1) end, on_destruct = lrfurn.on_seat_destruct, + on_movenode = lrfurn.on_seat_movenode, }) end diff --git a/homedecor_seating/sofas.lua b/homedecor_seating/sofas.lua index 130f9c58..ff1f3c95 100644 --- a/homedecor_seating/sofas.lua +++ b/homedecor_seating/sofas.lua @@ -49,6 +49,7 @@ minetest.register_node(":lrfurn:sofa", { return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 2) end, on_destruct = lrfurn.on_seat_destruct, + on_movenode = lrfurn.on_seat_movenode, }) minetest.register_craft({