From 883a8484b5dd43be50c0d8bc60db125ff225b260 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Fri, 11 Oct 2019 08:32:03 +0200 Subject: [PATCH] fix stored player object, use name instead --- init.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index b24d6c4..e62a3f7 100644 --- a/init.lua +++ b/init.lua @@ -22,6 +22,7 @@ lightning.auto = true local rng = PcgRandom(32321123312123) +-- table with playername as key and previous skybox as value local ps = {} local ttl = 1 @@ -34,9 +35,12 @@ local revertsky = function() return end - for _, entry in pairs(ps) do - local sky = entry.sky - entry.p:set_sky(sky.bgcolor, sky.type, sky.textures) + for playername, sky in pairs(ps) do + local player = minetest.get_player_by_name(playername) + -- check if the player is still online + if player then + player:set_sky(sky.bgcolor, sky.type, sky.textures) + end end ps = {} @@ -140,7 +144,7 @@ lightning.strike = function(pos) local name = player:get_player_name() if ps[name] == nil then - ps[name] = {p = player, sky = sky} + ps[name] = sky player:set_sky(0xffffff, "plain", {}) end end