Fix player sky race.
Fixes a bug that would leave the player's sky permanently white after two lightning strikes occur in rapid succession.
This commit is contained in:
parent
846079370f
commit
1d9dfaa785
18
init.lua
18
init.lua
@ -34,8 +34,9 @@ local revertsky = function()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, table.getn(ps) do
|
for key, entry in pairs(ps) do
|
||||||
ps[i].p:set_sky(ps[i].sky.bgcolor, ps[i].sky.type, ps[i].sky.textures)
|
local sky = entry.sky
|
||||||
|
entry.p:set_sky(sky.bgcolor, sky.type, sky.textures)
|
||||||
end
|
end
|
||||||
|
|
||||||
ps = {}
|
ps = {}
|
||||||
@ -130,11 +131,18 @@ lightning.strike = function(pos)
|
|||||||
|
|
||||||
local playerlist = minetest.get_connected_players()
|
local playerlist = minetest.get_connected_players()
|
||||||
for i = 1, #playerlist do
|
for i = 1, #playerlist do
|
||||||
|
local player = playerlist[i]
|
||||||
local sky = {}
|
local sky = {}
|
||||||
sky.bgcolor, sky.type, sky.textures = playerlist[i]:get_sky()
|
|
||||||
table.insert(ps, { p = playerlist[i], sky = sky})
|
sky.bgcolor, sky.type, sky.textures = player:get_sky()
|
||||||
playerlist[i]:set_sky(0xffffff, "plain", {})
|
|
||||||
|
local name = player:get_player_name()
|
||||||
|
if ps[name] == nil then
|
||||||
|
ps[name] = {p = player, sky = sky}
|
||||||
|
player:set_sky(0xffffff, "plain", {})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- trigger revert of skybox
|
-- trigger revert of skybox
|
||||||
ttl = 5
|
ttl = 5
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user