mirror of
https://github.com/mt-mods/homedecor_modpack.git
synced 2024-12-22 08:00:18 +01:00
free player when seat is dug (#84)
This commit is contained in:
parent
d8ae7a360d
commit
94e25c2192
@ -33,7 +33,8 @@ minetest.register_node(":lrfurn:armchair", {
|
||||
on_rotate = unifieddyes.fix_after_screwdriver_nsew,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1)
|
||||
end
|
||||
end,
|
||||
on_destruct = lrfurn.on_seat_destruct,
|
||||
})
|
||||
|
||||
homedecor.register("armchair", {
|
||||
@ -59,7 +60,8 @@ homedecor.register("armchair", {
|
||||
on_rotate = unifieddyes.fix_after_screwdriver_nsew,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1)
|
||||
end
|
||||
end,
|
||||
on_destruct = lrfurn.on_seat_destruct,
|
||||
})
|
||||
|
||||
-- crafts
|
||||
|
@ -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
|
||||
|
@ -47,7 +47,8 @@ minetest.register_node(":lrfurn:longsofa", {
|
||||
on_dig = unifieddyes.on_dig,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 3)
|
||||
end
|
||||
end,
|
||||
on_destruct = lrfurn.on_seat_destruct,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
|
@ -22,7 +22,8 @@ homedecor.register("deckchair", {
|
||||
on_rotate = minetest.get_modpath("screwdriver") and screwdriver.disallow or nil,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
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")
|
||||
@ -42,7 +43,8 @@ homedecor.register("deckchair_striped_blue", {
|
||||
on_rotate = minetest.get_modpath("screwdriver") and screwdriver.disallow or nil,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1)
|
||||
end
|
||||
end,
|
||||
on_destruct = lrfurn.on_seat_destruct,
|
||||
})
|
||||
|
||||
homedecor.register("simple_bench", {
|
||||
@ -62,7 +64,8 @@ homedecor.register("simple_bench", {
|
||||
},
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1)
|
||||
end
|
||||
end,
|
||||
on_destruct = lrfurn.on_seat_destruct,
|
||||
})
|
||||
|
||||
local bl1_sbox = {
|
||||
@ -154,7 +157,8 @@ homedecor.register("kitchen_chair_wood", {
|
||||
on_rotate = unifieddyes.fix_after_screwdriver_nsew,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1)
|
||||
end
|
||||
end,
|
||||
on_destruct = lrfurn.on_seat_destruct,
|
||||
})
|
||||
|
||||
homedecor.register("kitchen_chair_padded", {
|
||||
@ -180,7 +184,8 @@ homedecor.register("kitchen_chair_padded", {
|
||||
on_rotate = unifieddyes.fix_after_screwdriver_nsew,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1)
|
||||
end
|
||||
end,
|
||||
on_destruct = lrfurn.on_seat_destruct,
|
||||
})
|
||||
|
||||
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_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 1)
|
||||
end
|
||||
end,
|
||||
on_destruct = lrfurn.on_seat_destruct,
|
||||
})
|
||||
end
|
||||
|
||||
|
@ -47,7 +47,8 @@ minetest.register_node(":lrfurn:sofa", {
|
||||
on_dig = unifieddyes.on_dig,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
return lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, 2)
|
||||
end
|
||||
end,
|
||||
on_destruct = lrfurn.on_seat_destruct,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
|
Loading…
Reference in New Issue
Block a user