From 64f9e39ebdf051f79f3df7ba89945eae52bc200e Mon Sep 17 00:00:00 2001 From: kay27 Date: Thu, 30 Jul 2020 03:59:30 +0400 Subject: [PATCH] slighty optimize the code --- mods/ITEMS/mcl_beds/functions.lua | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index d93b2b84d2..b1a0ce4fdd 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -202,13 +202,8 @@ local function lay_down(player, pos, bed_pos, state, skip) return true end -local function update_formspecs(finished, players) - local ges - if players then - ges = #players - else - ges = #minetest.get_connected_players() - end +local function update_formspecs(finished, ges) + local ges = ges or #minetest.get_connected_players() local form_n = "size[6,5;true]" local all_in_bed = ges == player_in_bed local night_skip = is_night_skip_enabled() @@ -384,7 +379,7 @@ minetest.register_on_leaveplayer(function(player) end end) end - update_formspecs(false, players) + update_formspecs(false, #players) end) minetest.register_on_player_receive_fields(function(player, formname, fields)