fix stored player object, use name instead

This commit is contained in:
BuckarooBanzay 2019-10-11 08:32:03 +02:00 committed by SmallJoker
parent 3136adbe00
commit 883a8484b5
1 changed files with 8 additions and 4 deletions

View File

@ -22,6 +22,7 @@ lightning.auto = true
local rng = PcgRandom(32321123312123) local rng = PcgRandom(32321123312123)
-- table with playername as key and previous skybox as value
local ps = {} local ps = {}
local ttl = 1 local ttl = 1
@ -34,9 +35,12 @@ local revertsky = function()
return return
end end
for _, entry in pairs(ps) do for playername, sky in pairs(ps) do
local sky = entry.sky local player = minetest.get_player_by_name(playername)
entry.p:set_sky(sky.bgcolor, sky.type, sky.textures) -- check if the player is still online
if player then
player:set_sky(sky.bgcolor, sky.type, sky.textures)
end
end end
ps = {} ps = {}
@ -140,7 +144,7 @@ lightning.strike = function(pos)
local name = player:get_player_name() local name = player:get_player_name()
if ps[name] == nil then if ps[name] == nil then
ps[name] = {p = player, sky = sky} ps[name] = sky
player:set_sky(0xffffff, "plain", {}) player:set_sky(0xffffff, "plain", {})
end end
end end