Add excessive checks for player skybox
This commit is contained in:
parent
df520f8a39
commit
c70d5956f7
124
skybox.lua
124
skybox.lua
|
@ -682,6 +682,10 @@ local skybox_defs = {
|
||||||
}
|
}
|
||||||
|
|
||||||
local function should_flip(player)
|
local function should_flip(player)
|
||||||
|
if not player then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local player_meta = player:get_meta()
|
local player_meta = player:get_meta()
|
||||||
local player_time = player_meta:get_int('everness_timeofday')
|
local player_time = player_meta:get_int('everness_timeofday')
|
||||||
-- 0 not defined (for player meta)
|
-- 0 not defined (for player meta)
|
||||||
|
@ -728,6 +732,10 @@ minetest.register_globalstep(function(dtime)
|
||||||
|
|
||||||
local should_flip_data = should_flip(player)
|
local should_flip_data = should_flip(player)
|
||||||
|
|
||||||
|
if not should_flip_data then
|
||||||
|
should_flip_data = {}
|
||||||
|
end
|
||||||
|
|
||||||
-- flip sun/moon when morning/afternoon
|
-- flip sun/moon when morning/afternoon
|
||||||
if player_biome_name == biome_name and should_flip_data.should_flip then
|
if player_biome_name == biome_name and should_flip_data.should_flip then
|
||||||
if skybox_defs[biome_name] then
|
if skybox_defs[biome_name] then
|
||||||
|
@ -738,7 +746,9 @@ minetest.register_globalstep(function(dtime)
|
||||||
sun_params.texture = sun_params.texture .. '^[transformFY'
|
sun_params.texture = sun_params.texture .. '^[transformFY'
|
||||||
end
|
end
|
||||||
|
|
||||||
player:set_sun(sun_params)
|
if player then
|
||||||
|
player:set_sun(sun_params)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if skybox_defs[biome_name].moon_parameters then
|
-- if skybox_defs[biome_name].moon_parameters then
|
||||||
|
@ -761,40 +771,70 @@ minetest.register_globalstep(function(dtime)
|
||||||
sun_params.texture = sun_params.texture .. '^[transformFY'
|
sun_params.texture = sun_params.texture .. '^[transformFY'
|
||||||
end
|
end
|
||||||
|
|
||||||
player:set_sun(sun_params)
|
if player then
|
||||||
|
player:set_sun(sun_params)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
player:set_sun()
|
if player then
|
||||||
|
player:set_sun()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if skybox_defs[biome_name].moon_parameters then
|
if skybox_defs[biome_name].moon_parameters then
|
||||||
player:set_moon(skybox_defs[biome_name].moon_parameters)
|
if player then
|
||||||
|
player:set_moon(skybox_defs[biome_name].moon_parameters)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
player:set_moon()
|
if player then
|
||||||
|
player:set_moon()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if skybox_defs[biome_name].star_parameters then
|
if skybox_defs[biome_name].star_parameters then
|
||||||
player:set_stars(skybox_defs[biome_name].star_parameters)
|
if player then
|
||||||
|
player:set_stars(skybox_defs[biome_name].star_parameters)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
player:set_stars()
|
if player then
|
||||||
|
player:set_stars()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if skybox_defs[biome_name].sky_parameters then
|
if skybox_defs[biome_name].sky_parameters then
|
||||||
player:set_sky(skybox_defs[biome_name].sky_parameters)
|
if player then
|
||||||
|
player:set_sky(skybox_defs[biome_name].sky_parameters)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
player:set_sky()
|
if player then
|
||||||
|
player:set_sky()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if skybox_defs[biome_name].cloud_parameters then
|
if skybox_defs[biome_name].cloud_parameters then
|
||||||
player:set_clouds(skybox_defs[biome_name].cloud_parameters)
|
if player then
|
||||||
|
player:set_clouds(skybox_defs[biome_name].cloud_parameters)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
player:set_clouds()
|
if player then
|
||||||
|
player:set_clouds()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
player:set_sun()
|
if player then
|
||||||
player:set_moon()
|
player:set_sun()
|
||||||
player:set_stars()
|
end
|
||||||
player:set_sky()
|
if player then
|
||||||
player:set_clouds()
|
player:set_moon()
|
||||||
|
end
|
||||||
|
if player then
|
||||||
|
player:set_stars()
|
||||||
|
end
|
||||||
|
if player then
|
||||||
|
player:set_sky()
|
||||||
|
end
|
||||||
|
if player then
|
||||||
|
player:set_clouds()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -802,35 +842,47 @@ minetest.register_globalstep(function(dtime)
|
||||||
-- hide sun, moon, stars ... underground
|
-- hide sun, moon, stars ... underground
|
||||||
player_meta:set_int('everness_is_underground', 1)
|
player_meta:set_int('everness_is_underground', 1)
|
||||||
|
|
||||||
player:set_sun({
|
if player then
|
||||||
visible = false,
|
player:set_sun({
|
||||||
sunrise_visible = false
|
visible = false,
|
||||||
})
|
sunrise_visible = false
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
player:set_moon({
|
if player then
|
||||||
visible = false
|
player:set_moon({
|
||||||
})
|
visible = false
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
player:set_stars({
|
if player then
|
||||||
visible = false
|
player:set_stars({
|
||||||
})
|
visible = false
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
elseif player_pos.y > -256 and is_underground ~= 0 or (is_underground == 0 and player_meta:get_string('everness_biome_name') ~= biome_name) then
|
elseif player_pos.y > -256 and is_underground ~= 0 or (is_underground == 0 and player_meta:get_string('everness_biome_name') ~= biome_name) then
|
||||||
-- show sun, moon, stars ... underground
|
-- show sun, moon, stars ... underground
|
||||||
player_meta:set_int('everness_is_underground', 0)
|
player_meta:set_int('everness_is_underground', 0)
|
||||||
|
|
||||||
player:set_sun({
|
if player then
|
||||||
visible = true
|
player:set_sun({
|
||||||
})
|
visible = true
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
player:set_moon({
|
if player then
|
||||||
visible = true
|
player:set_moon({
|
||||||
})
|
visible = true
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
player:set_stars({
|
if player then
|
||||||
visible = true,
|
player:set_stars({
|
||||||
sunrise_visible = true
|
visible = true,
|
||||||
})
|
sunrise_visible = true
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Ŝarĝante…
Reference in New Issue