mirror of
https://github.com/minetest/minetest_game.git
synced 2025-01-06 21:40:17 +01:00
Kick players from beds that have ceased existing
This commit is contained in:
parent
a8f7a89dac
commit
49d874a4a1
@ -25,8 +25,15 @@ local function destruct_bed(pos, n)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
beds.is_bed_node = {}
|
||||||
|
|
||||||
|
local function register_bed_node(name, def)
|
||||||
|
beds.is_bed_node[name] = true
|
||||||
|
core.register_node(name, def)
|
||||||
|
end
|
||||||
|
|
||||||
function beds.register_bed(name, def)
|
function beds.register_bed(name, def)
|
||||||
minetest.register_node(name .. "_bottom", {
|
register_bed_node(name .. "_bottom", {
|
||||||
description = def.description,
|
description = def.description,
|
||||||
inventory_image = def.inventory_image,
|
inventory_image = def.inventory_image,
|
||||||
wield_image = def.wield_image,
|
wield_image = def.wield_image,
|
||||||
@ -150,7 +157,7 @@ function beds.register_bed(name, def)
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node(name .. "_top", {
|
register_bed_node(name .. "_top", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = def.tiles.top,
|
tiles = def.tiles.top,
|
||||||
use_texture_alpha = "clip",
|
use_texture_alpha = "clip",
|
||||||
|
@ -170,13 +170,24 @@ end
|
|||||||
|
|
||||||
-- Public functions
|
-- Public functions
|
||||||
|
|
||||||
|
function beds.kick_player(player)
|
||||||
|
lay_down(player, nil, nil, false)
|
||||||
|
end
|
||||||
|
|
||||||
function beds.kick_players()
|
function beds.kick_players()
|
||||||
for name, _ in pairs(beds.player) do
|
for name in pairs(beds.player) do
|
||||||
local player = minetest.get_player_by_name(name)
|
beds.kick_players(core.get_player_by_name(name))
|
||||||
lay_down(player, nil, nil, false)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
core.register_globalstep(function()
|
||||||
|
for name, bed_pos in pairs(beds.bed_position) do
|
||||||
|
if not beds.is_bed_node[core.get_node(bed_pos).name] then
|
||||||
|
beds.kick_player(core.get_player_by_name(name))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
function beds.skip_night()
|
function beds.skip_night()
|
||||||
minetest.set_timeofday(0.23)
|
minetest.set_timeofday(0.23)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user