mirror of
https://github.com/mt-mods/homedecor_modpack.git
synced 2024-11-17 15:48:31 +01:00
fix players in bed count for multiplayer (#404)
This commit is contained in:
parent
017326dbed
commit
a4ca53cc05
@ -2,7 +2,6 @@
|
|||||||
-- with changes needed for homedecor's beds.
|
-- with changes needed for homedecor's beds.
|
||||||
|
|
||||||
local pi = math.pi
|
local pi = math.pi
|
||||||
local player_in_bed = 0
|
|
||||||
local is_sp = minetest.is_singleplayer()
|
local is_sp = minetest.is_singleplayer()
|
||||||
local enable_respawn = minetest.settings:get_bool("enable_bed_respawn")
|
local enable_respawn = minetest.settings:get_bool("enable_bed_respawn")
|
||||||
if enable_respawn == nil then
|
if enable_respawn == nil then
|
||||||
@ -49,6 +48,14 @@ local function check_in_beds(players)
|
|||||||
return #players > 0
|
return #players > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function get_player_in_bed()
|
||||||
|
local player_in_bed = 0
|
||||||
|
for k,v in pairs(beds.player) do
|
||||||
|
player_in_bed = player_in_bed + 1
|
||||||
|
end
|
||||||
|
return player_in_bed
|
||||||
|
end
|
||||||
|
|
||||||
local function lay_down(player, pos, bed_pos, state, skip)
|
local function lay_down(player, pos, bed_pos, state, skip)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local hud_flags = player:hud_get_flags()
|
local hud_flags = player:hud_get_flags()
|
||||||
@ -62,7 +69,6 @@ local function lay_down(player, pos, bed_pos, state, skip)
|
|||||||
local p = beds.pos[name] or nil
|
local p = beds.pos[name] or nil
|
||||||
if beds.player[name] ~= nil then
|
if beds.player[name] ~= nil then
|
||||||
beds.player[name] = nil
|
beds.player[name] = nil
|
||||||
player_in_bed = player_in_bed - 1
|
|
||||||
end
|
end
|
||||||
-- skip here to prevent sending player specific changes (used for leaving players)
|
-- skip here to prevent sending player specific changes (used for leaving players)
|
||||||
if skip then
|
if skip then
|
||||||
@ -84,8 +90,6 @@ local function lay_down(player, pos, bed_pos, state, skip)
|
|||||||
else
|
else
|
||||||
beds.player[name] = 1
|
beds.player[name] = 1
|
||||||
beds.pos[name] = pos
|
beds.pos[name] = pos
|
||||||
player_in_bed = player_in_bed + 1
|
|
||||||
|
|
||||||
-- physics, eye_offset, etc
|
-- physics, eye_offset, etc
|
||||||
player:set_eye_offset({x = 0, y = -13, z = 0}, {x = 0, y = 0, z = 0})
|
player:set_eye_offset({x = 0, y = -13, z = 0}, {x = 0, y = 0, z = 0})
|
||||||
local yaw, fdir = get_look_yaw(bed_pos)
|
local yaw, fdir = get_look_yaw(bed_pos)
|
||||||
@ -109,6 +113,7 @@ end
|
|||||||
|
|
||||||
local function update_formspecs(finished)
|
local function update_formspecs(finished)
|
||||||
local ges = #minetest.get_connected_players()
|
local ges = #minetest.get_connected_players()
|
||||||
|
local player_in_bed = get_player_in_bed()
|
||||||
local form_n
|
local form_n
|
||||||
local is_majority = (ges / 2) < player_in_bed
|
local is_majority = (ges / 2) < player_in_bed
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user