1
0
mirror of https://github.com/mt-mods/homedecor_modpack.git synced 2024-12-22 16:10:18 +01:00

free player when seat is dug

This commit is contained in:
wsor4035 2024-11-06 23:21:40 -05:00
parent d8ae7a360d
commit f8ee689624
5 changed files with 32 additions and 11 deletions

View File

@ -33,7 +33,8 @@ minetest.register_node(":lrfurn:armchair", {
on_rotate = unifieddyes.fix_after_screwdriver_nsew, on_rotate = unifieddyes.fix_after_screwdriver_nsew,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1) return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1)
end end,
on_destruct = lrfurn.on_seat_destruct,
}) })
homedecor.register("armchair", { homedecor.register("armchair", {
@ -59,7 +60,8 @@ homedecor.register("armchair", {
on_rotate = unifieddyes.fix_after_screwdriver_nsew, on_rotate = unifieddyes.fix_after_screwdriver_nsew,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1) return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1)
end end,
on_destruct = lrfurn.on_seat_destruct,
}) })
-- crafts -- crafts

View File

@ -193,7 +193,7 @@ function lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, seats)
xcompat.player.player_attached[name] = true xcompat.player.player_attached[name] = true
xcompat.player.set_animation(clicker, "sit", 0) xcompat.player.set_animation(clicker, "sit", 0)
seated_cache[name] = true seated_cache[name] = minetest.hash_node_position(pos)
return itemstack return itemstack
end end
@ -210,6 +210,17 @@ function lrfurn.stand(clicker)
end end
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 --if the player gets killed in the seat, handle it
minetest.register_on_dieplayer(function(player) minetest.register_on_dieplayer(function(player)
if seated_cache[player:get_player_name()] then if seated_cache[player:get_player_name()] then

View File

@ -47,7 +47,8 @@ minetest.register_node(":lrfurn:longsofa", {
on_dig = unifieddyes.on_dig, on_dig = unifieddyes.on_dig,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 3) return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 3)
end end,
on_destruct = lrfurn.on_seat_destruct,
}) })
minetest.register_craft({ minetest.register_craft({

View File

@ -22,7 +22,8 @@ homedecor.register("deckchair", {
on_rotate = minetest.get_modpath("screwdriver") and screwdriver.disallow or nil, on_rotate = minetest.get_modpath("screwdriver") and screwdriver.disallow or nil,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1) return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1)
end end,
on_destruct = lrfurn.on_seat_destruct,
}) })
minetest.register_alias("homedecor:deckchair_foot", "homedecor:deckchair") minetest.register_alias("homedecor:deckchair_foot", "homedecor:deckchair")
@ -42,7 +43,8 @@ homedecor.register("deckchair_striped_blue", {
on_rotate = minetest.get_modpath("screwdriver") and screwdriver.disallow or nil, on_rotate = minetest.get_modpath("screwdriver") and screwdriver.disallow or nil,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1) return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1)
end end,
on_destruct = lrfurn.on_seat_destruct,
}) })
homedecor.register("simple_bench", { homedecor.register("simple_bench", {
@ -62,7 +64,8 @@ homedecor.register("simple_bench", {
}, },
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1) return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1)
end end,
on_destruct = lrfurn.on_seat_destruct,
}) })
local bl1_sbox = { local bl1_sbox = {
@ -154,7 +157,8 @@ homedecor.register("kitchen_chair_wood", {
on_rotate = unifieddyes.fix_after_screwdriver_nsew, on_rotate = unifieddyes.fix_after_screwdriver_nsew,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1) return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1)
end end,
on_destruct = lrfurn.on_seat_destruct,
}) })
homedecor.register("kitchen_chair_padded", { homedecor.register("kitchen_chair_padded", {
@ -180,7 +184,8 @@ homedecor.register("kitchen_chair_padded", {
on_rotate = unifieddyes.fix_after_screwdriver_nsew, on_rotate = unifieddyes.fix_after_screwdriver_nsew,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1) return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1)
end end,
on_destruct = lrfurn.on_seat_destruct,
}) })
local ofchairs_sbox = { local ofchairs_sbox = {
@ -219,7 +224,8 @@ for _, c in pairs(chairs) do
on_rotate = minetest.get_modpath("screwdriver") and screwdriver.rotate_simple or nil, on_rotate = minetest.get_modpath("screwdriver") and screwdriver.rotate_simple or nil,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1) return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1)
end end,
on_destruct = lrfurn.on_seat_destruct,
}) })
end end

View File

@ -47,7 +47,8 @@ minetest.register_node(":lrfurn:sofa", {
on_dig = unifieddyes.on_dig, on_dig = unifieddyes.on_dig,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 2) return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 2)
end end,
on_destruct = lrfurn.on_seat_destruct,
}) })
minetest.register_craft({ minetest.register_craft({