2020-04-13 01:55:39 +02:00
|
|
|
local environment = {}
|
2020-04-09 20:25:02 +02:00
|
|
|
|
2020-04-13 01:55:39 +02:00
|
|
|
local function get_heat_time()
|
|
|
|
local time = minetest.get_timeofday()
|
2020-04-13 13:40:05 +02:00
|
|
|
return climate_api.utility.normalized_cycle(time) * 0.6 + 0.7
|
2020-04-09 20:25:02 +02:00
|
|
|
end
|
|
|
|
|
2020-04-13 01:55:39 +02:00
|
|
|
local function get_heat_calendar()
|
|
|
|
-- European heat center in August instead of June
|
2020-04-13 13:40:05 +02:00
|
|
|
local day = minetest.get_day_count()
|
2020-04-13 16:53:32 +02:00
|
|
|
local progression = ((day + 61) % 365) / 365
|
2020-04-13 13:40:05 +02:00
|
|
|
return climate_api.utility.normalized_cycle(progression) * 0.6 + 0.7
|
2020-04-09 09:03:02 +02:00
|
|
|
end
|
|
|
|
|
2020-04-13 01:55:39 +02:00
|
|
|
local function get_heat_height(y)
|
2020-04-13 13:40:05 +02:00
|
|
|
return climate_api.utility.rangelim((-y + 10) / 15, -10, 10)
|
2020-04-09 18:31:52 +02:00
|
|
|
end
|
|
|
|
|
2020-04-13 01:55:39 +02:00
|
|
|
function environment.get_heat(pos)
|
|
|
|
local base = climate_mod.settings.heat
|
|
|
|
local biome = minetest.get_heat(pos)
|
|
|
|
local height = get_heat_height(pos.y)
|
|
|
|
local time = get_heat_time()
|
|
|
|
local date = get_heat_calendar()
|
2020-04-13 13:40:05 +02:00
|
|
|
local random = climate_mod.state:get_float("heat_random");
|
|
|
|
return (base + biome + height) * time * date * random
|
2020-04-09 09:03:02 +02:00
|
|
|
end
|
|
|
|
|
2020-04-13 01:55:39 +02:00
|
|
|
function environment.get_humidity(pos)
|
|
|
|
local base = climate_mod.settings.humidity
|
|
|
|
local biome = minetest.get_humidity(pos)
|
2020-04-13 13:40:05 +02:00
|
|
|
local random = climate_mod.state:get_float("humidity_random");
|
|
|
|
local random_base = climate_mod.state:get_float("humidity_base");
|
|
|
|
--[[for _, player in ipairs(minetest.get_connected_players()) do
|
|
|
|
local pname = player:get_player_name()
|
|
|
|
minetest.chat_send_player(pname, dump2(biome, "biome"))
|
|
|
|
minetest.chat_send_player(pname, dump2(random_base, "random_base"))
|
|
|
|
minetest.chat_send_player(pname, dump2(random, "random"))
|
|
|
|
minetest.chat_send_player(pname, dump2((base + biome * 0.7 + random_base * 0.3) * random, "total"))
|
|
|
|
end]]
|
|
|
|
return (base + biome * 0.7 + random_base * 0.3) * random
|
2020-04-09 20:25:02 +02:00
|
|
|
end
|
|
|
|
|
2020-04-14 05:44:46 +02:00
|
|
|
function environment.get_weather_presets(player)
|
|
|
|
local pname = player:get_player_name()
|
|
|
|
local weathers = climate_mod.current_weather[pname]
|
|
|
|
if type(weathers) == "nil" then weathers = {} end
|
|
|
|
return weathers
|
|
|
|
end
|
|
|
|
|
|
|
|
function environment.get_effects(player)
|
|
|
|
local pname = player:get_player_name()
|
|
|
|
local effects = {}
|
|
|
|
for effect, players in pairs(climate_mod.current_effects) do
|
|
|
|
if type(players[pname]) ~= "nil" then
|
|
|
|
table.insert(effects, effect)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return effects
|
|
|
|
end
|
|
|
|
|
2020-04-13 01:55:39 +02:00
|
|
|
return environment
|