Skip to content

Commit

Permalink
psuedo code for jump drive support
Browse files Browse the repository at this point in the history
  • Loading branch information
wsor4035 committed Nov 8, 2024
1 parent 94e25c2 commit b571050
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions homedecor_seating/armchairs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions homedecor_seating/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions homedecor_seating/longsofas.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
6 changes: 6 additions & 0 deletions homedecor_seating/misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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", {
Expand All @@ -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 = {
Expand Down Expand Up @@ -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", {
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions homedecor_seating/sofas.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit b571050

Please sign in to comment.