diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1bb4614 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.code-workspace \ No newline at end of file diff --git a/lib/commands.lua b/lib/commands.lua index 30de693..8189efa 100644 --- a/lib/commands.lua +++ b/lib/commands.lua @@ -229,4 +229,19 @@ minetest.register_chatcommand("weather_influences", { minetest.chat_send_player(playername, dump2(value, influence)) end end +}) + +-- used to debug downfall +minetest.register_chatcommand("explain_humidity", { + description = "Explains how the humidity value got calculated", + func = function(playername) + local base = climate_mod.settings.humidity + local biome = minetest.get_humidity((minetest.get_player_by_name(playername)):get_pos()) + local random = climate_mod.state:get_float("humidity_random"); + local random_base = climate_mod.state:get_float("humidity_base"); + minetest.chat_send_player(playername, dump2(base, "base")) + minetest.chat_send_player(playername, dump2(biome, "biome")) + minetest.chat_send_player(playername, dump2(random, "random")) + minetest.chat_send_player(playername, dump2(random_base, "random_base")) + end }) \ No newline at end of file diff --git a/lib/environment.lua b/lib/environment.lua index 3d369d9..b9afcf5 100644 --- a/lib/environment.lua +++ b/lib/environment.lua @@ -9,7 +9,7 @@ function environment.get_heat(pos) local height = climate_api.utility.rangelim((-pos.y + 10) / 15, -10, 10) local time = climate_api.utility.normalized_cycle(minetest.get_timeofday()) * 0.6 + 0.7 local random = climate_mod.state:get_float("heat_random"); - return (base + biome + height) * time * random + return base + ((biome + height) * time * random) end function environment.get_humidity(pos) @@ -19,8 +19,7 @@ function environment.get_humidity(pos) local base = climate_mod.settings.humidity local biome = minetest.get_humidity(pos) local random = climate_mod.state:get_float("humidity_random"); - local random_base = climate_mod.state:get_float("humidity_base"); - return (base + biome * 0.7 + random_base * 0.3) * random + return base + (((biome + 40) / 2) * random) end function environment.get_wind(pos) diff --git a/lib/trigger.lua b/lib/trigger.lua index eea1879..c71c108 100644 --- a/lib/trigger.lua +++ b/lib/trigger.lua @@ -9,7 +9,7 @@ function trigger.get_global_environment() end function trigger.get_position_environment(pos) - local env = table.copy(climate_mod.global_environment) + local env = trigger.get_global_environment() for influence, func in pairs(climate_mod.influences) do env[influence] = func(pos) end diff --git a/lib/world.lua b/lib/world.lua index 4f9b92c..63eb027 100644 --- a/lib/world.lua +++ b/lib/world.lua @@ -6,9 +6,9 @@ local WIND_SCALE = 2 local HEAT_SPREAD = 400 local HEAT_SCALE = 0.3 local HUMIDITY_SPREAD = 150 -local HUMIDITY_SCALE = 0.5 +local HUMIDITY_SCALE = 1 local HUMIDITY_BASE_SPREAD = 800 -local HUMIDITY_BASE_SCALE = 40 +local HUMIDITY_BASE_SCALE = 20 local nobj_wind_x local nobj_wind_z @@ -47,23 +47,14 @@ local pn_heat = { } local pn_humidity = { - offset = 0, + offset = 1, scale = HUMIDITY_SCALE, spread = {x = HUMIDITY_SPREAD, y = HUMIDITY_SPREAD, z = HUMIDITY_SPREAD}, seed = 8374061, octaves = 2, persist = 0.5, - lacunarity = 2 -} - -local pn_humidity_base = { - offset = 50, - scale = HUMIDITY_BASE_SCALE, - spread = {x = HUMIDITY_BASE_SPREAD, y = HUMIDITY_BASE_SPREAD, z = HUMIDITY_BASE_SPREAD}, - seed = 3803465, - octaves = 2, - persist = 0.5, - lacunarity = 2 + lacunarity = 2, + flags = "noeased" } local function update_wind(timer) @@ -83,11 +74,8 @@ end local function update_humidity(timer) nobj_humidity = nobj_humidity or minetest.get_perlin(pn_humidity) - local n_humidity = nobj_humidity:get_2d({x = timer, y = 0}) + local n_humidity = nobj_humidity:get_2d({x = timer * 3, y = 0}) climate_mod.state:set_float("humidity_random", n_humidity) - nobj_humidity_base = nobj_humidity_base or minetest.get_perlin(pn_humidity_base) - local n_humidity_base = nobj_humidity_base:get_2d({x = timer, y = 0}) - climate_mod.state:set_float("humidity_base", n_humidity_base) end function world.update_status(timer)