From d1bdf929374bbd2be35bd41f726bb3c583d776eb Mon Sep 17 00:00:00 2001 From: Till Affeldt Date: Sat, 18 Apr 2020 19:13:47 +0200 Subject: [PATCH] Fix reset of skybox --- ca_effects/skybox.lua | 28 +++++++++----------------- lib/sky_defaults.lua | 46 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 19 deletions(-) create mode 100644 lib/sky_defaults.lua diff --git a/ca_effects/skybox.lua b/ca_effects/skybox.lua index 09f52df..a2692d4 100644 --- a/ca_effects/skybox.lua +++ b/ca_effects/skybox.lua @@ -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 diff --git a/lib/sky_defaults.lua b/lib/sky_defaults.lua new file mode 100644 index 0000000..0f37578 --- /dev/null +++ b/lib/sky_defaults.lua @@ -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 + } +} \ No newline at end of file