fix stored player object, use name instead
This commit is contained in:
parent
3136adbe00
commit
883a8484b5
12
init.lua
12
init.lua
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user