mirror of
https://github.com/t-affeldt/climate_api.git
synced 2025-06-30 15:30:43 +02:00
Add skybox merging utility, remove date bases heat, tweak noise settings
This commit is contained in:
@ -38,6 +38,8 @@ function api.register_influence(name, func)
|
||||
end
|
||||
|
||||
function api.register_abm(config)
|
||||
if not climate_mod.settings.block_updates then return end
|
||||
|
||||
local conditions = config.conditions
|
||||
local action = config.action
|
||||
local pos_override = config.pos_override
|
||||
|
@ -5,13 +5,6 @@ local function get_heat_time()
|
||||
return climate_api.utility.normalized_cycle(time) * 0.6 + 0.7
|
||||
end
|
||||
|
||||
local function get_heat_calendar()
|
||||
-- heat center in August instead of June
|
||||
local day = minetest.get_day_count()
|
||||
local progression = ((day + 61) % 365) / 365
|
||||
return climate_api.utility.normalized_cycle(progression) * 0.6 + 0.7
|
||||
end
|
||||
|
||||
local function get_heat_height(y)
|
||||
return climate_api.utility.rangelim((-y + 10) / 15, -10, 10)
|
||||
end
|
||||
@ -21,9 +14,8 @@ function environment.get_heat(pos)
|
||||
local biome = minetest.get_heat(pos)
|
||||
local height = get_heat_height(pos.y)
|
||||
local time = get_heat_time()
|
||||
local date = get_heat_calendar()
|
||||
local random = climate_mod.state:get_float("heat_random");
|
||||
return (base + biome + height) * time * date * random
|
||||
return (base + biome + height) * time * random
|
||||
end
|
||||
|
||||
function environment.get_humidity(pos)
|
||||
|
@ -1,46 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
109
lib/skybox_merger.lua
Normal file
109
lib/skybox_merger.lua
Normal file
@ -0,0 +1,109 @@
|
||||
local default_sky = {
|
||||
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 = "",
|
||||
tonemap = "sun_tonemap.png",
|
||||
sunrise = "sunrisebg.png",
|
||||
sunrise_visible = true,
|
||||
scale = 1
|
||||
},
|
||||
moon_data = {
|
||||
visible = true,
|
||||
texture = "",
|
||||
tonemap = "moon_tonemap.png",
|
||||
scale = 1
|
||||
},
|
||||
star_data = {
|
||||
visible = true,
|
||||
count = 1000,
|
||||
star_color = "#ebebff69",
|
||||
scale = 1
|
||||
}
|
||||
}
|
||||
|
||||
local skybox = {}
|
||||
local layers = {}
|
||||
|
||||
-- from https://stackoverflow.com/a/29133654
|
||||
-- merges two tables together
|
||||
-- if in conflict, b will override values of a
|
||||
local function merge_tables(a, b)
|
||||
if type(a) == "table" and type(b) == "table" then
|
||||
for k,v in pairs(b) do
|
||||
if type(v)=="table" and type(a[k] or false)=="table" then
|
||||
merge_tables(a[k],v)
|
||||
else a[k]=v end
|
||||
end
|
||||
end
|
||||
return a
|
||||
end
|
||||
|
||||
local function set_skybox(playername, sky)
|
||||
local player = minetest.get_player_by_name(playername)
|
||||
if not player.get_stars then return 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
|
||||
|
||||
function skybox.update_skybox(playername)
|
||||
local p_layers = layers[playername]
|
||||
local sky = table.copy(default_sky)
|
||||
if p_layers == nil then p_layers = {} end
|
||||
local numbered_layers = {}
|
||||
for layer, values in pairs(p_layers) do
|
||||
table.insert(numbered_layers, values)
|
||||
end
|
||||
table.sort(numbered_layers, function(left, right)
|
||||
if left.priority == nil then left.priority = 1 end
|
||||
if right.priority == nil then right.priority = 1 end
|
||||
return left.priority < right.priority
|
||||
end)
|
||||
for i=1,#numbered_layers do
|
||||
sky = merge_tables(sky, numbered_layers[i])
|
||||
end
|
||||
set_skybox(playername, sky)
|
||||
end
|
||||
|
||||
function skybox.add_layer(playername, name, sky)
|
||||
if layers[playername] == nil then layers[playername] = {} end
|
||||
layers[playername][name] = sky
|
||||
end
|
||||
|
||||
function skybox.remove_layer(playername, name)
|
||||
if layers[playername] == nil or layers[playername][name] == nil then return end
|
||||
layers[playername][name] = nil
|
||||
end
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local playername = player:get_player_name()
|
||||
layers[playername] = nil
|
||||
end)
|
||||
|
||||
return skybox
|
@ -2,11 +2,11 @@ local world = {}
|
||||
|
||||
local WIND_SPREAD = 600
|
||||
local WIND_SCALE = 2
|
||||
local HEAT_SPREAD = 200
|
||||
local HEAT_SPREAD = 400
|
||||
local HEAT_SCALE = 0.3
|
||||
local HUMIDITY_SPREAD = 60
|
||||
local HUMIDITY_SPREAD = 150
|
||||
local HUMIDITY_SCALE = 0.5
|
||||
local HUMIDITY_BASE_SPREAD = 600
|
||||
local HUMIDITY_BASE_SPREAD = 800
|
||||
local HUMIDITY_BASE_SCALE = 40
|
||||
|
||||
local nobj_wind_x
|
||||
|
Reference in New Issue
Block a user