Fix reset of skybox

This commit is contained in:
Till Affeldt 2020-04-18 19:13:47 +02:00
parent 0c5c9f0d15
commit d1bdf92937
2 changed files with 55 additions and 19 deletions

View File

@ -1,26 +1,16 @@
if not climate_mod.settings.skybox then return end
local EFFECT_NAME = "climate_api:skybox"
local reset_data = {}
local modpath = minetest.get_modpath(minetest.get_current_modname())
local sky_defaults = dofile(modpath .. "/lib/sky_defaults.lua")
local function set_skybox(player, sky)
if not player.get_stars then return end
if sky.sky_data ~= nil then
player:set_sky(sky.sky_data)
end
if sky.cloud_data ~= nil then
player:set_clouds(sky.cloud_data)
end
if sky.moon_data ~= nil then
player:set_moon(sky.moon_data)
end
if sky.sun_data ~= nil then
player:set_sun(sky.sun_data)
end
if sky.star_data ~= nil then
player:set_stars(sky.stars_data)
end
player:set_sky(sky.sky_data)
player:set_clouds(sky.cloud_data)
player:set_moon(sky.moon_data)
player:set_sun(sky.sun_data)
player:set_stars(sky.star_data)
end
local function remove_skybox(player)
@ -31,9 +21,9 @@ end
local function handle_effect(player_data)
for playername, data in pairs(player_data) do
local player = minetest.get_player_by_name(playername)
local sky = {}
local sky = table.copy(sky_defaults)
for weather, value in pairs(data) do
climate_api.utility.merge_tables(sky, value)
sky = climate_api.utility.merge_tables(sky, value)
end
set_skybox(player, sky)
end

46
lib/sky_defaults.lua Normal file
View File

@ -0,0 +1,46 @@
return {
sky_data = {
base_color = nil,
type = "regular",
textures = nil,
clouds = true,
sky_color = {
day_sky = "#8cbafa",
day_horizon = "#9bc1f0",
dawn_sky = "#b4bafa",
dawn_horizon = "#bac1f0",
night_sky = "#006aff",
night_horizon = "#4090ff",
indoors = "#646464",
fog_tint_type = "default"
}
},
cloud_data = {
density = 0.4,
color = "#fff0f0e5",
ambient = "#000000",
height = 120,
thickness = 16,
speed = {x=0, z=-2}
},
sun_data = {
visible = true,
texture = "sun.png",
tonemap = "sun_tonemap.png",
sunrise = "sunrisebg.png",
sunrise_visible = true,
scale = 1
},
moon_data = {
visible = true,
texture = "moon.png",
tonemap = "moon_tonemap.png",
scale = 1
},
star_data = {
visible = true,
count = 1000,
star_color = "#ebebff69",
scale = 1
}
}