free player when seat is dug (#84)

This commit is contained in:
wsor4035
2024-11-06 23:32:14 -05:00
committed by GitHub
parent d8ae7a360d
commit 94e25c2192
5 changed files with 32 additions and 11 deletions

View File

@ -193,7 +193,7 @@ function lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, seats)
xcompat.player.player_attached[name] = true
xcompat.player.set_animation(clicker, "sit", 0)
seated_cache[name] = true
seated_cache[name] = minetest.hash_node_position(pos)
return itemstack
end
@ -210,6 +210,17 @@ function lrfurn.stand(clicker)
end
end
function lrfurn.on_seat_destruct(pos) --called when a seat is destroyed
for name, seatpos in pairs(seated_cache) do
if seatpos == minetest.hash_node_position(pos) then
local player = minetest.get_player_by_name(name)
if player then
lrfurn.stand(player)
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