2020-05-12 16:00:24 +02:00
|
|
|
climate_api.register_influence("heat",
|
|
|
|
climate_api.environment.get_heat
|
|
|
|
)
|
2020-04-14 11:25:00 +02:00
|
|
|
|
2020-05-12 16:00:24 +02:00
|
|
|
climate_api.register_influence("base_heat",
|
|
|
|
minetest.get_heat
|
|
|
|
)
|
2020-04-18 17:24:59 +02:00
|
|
|
|
2020-05-12 16:00:24 +02:00
|
|
|
climate_api.register_influence("humidity",
|
|
|
|
climate_api.environment.get_humidity
|
|
|
|
)
|
2020-04-14 11:25:00 +02:00
|
|
|
|
2023-02-24 09:50:51 +01:00
|
|
|
climate_api.register_influence("biome_humidity",
|
2020-05-12 16:00:24 +02:00
|
|
|
minetest.get_humidity
|
|
|
|
)
|
2020-04-18 17:24:59 +02:00
|
|
|
|
2020-04-28 01:22:27 +02:00
|
|
|
-- see https://en.wikipedia.org/wiki/Dew_point#Simple_approximation
|
|
|
|
climate_api.register_influence("dewpoint", function(pos)
|
|
|
|
local heat = climate_api.environment.get_heat(pos)
|
|
|
|
local humidity = climate_api.environment.get_humidity(pos)
|
|
|
|
return heat - (9/25 * (100 - humidity))
|
|
|
|
end)
|
|
|
|
|
|
|
|
climate_api.register_influence("base_dewpoint", function(pos)
|
|
|
|
local heat = minetest.get_heat(pos)
|
|
|
|
local humidity = minetest.get_humidity(pos)
|
|
|
|
return heat - (9/25 * (100 - humidity))
|
|
|
|
end)
|
|
|
|
|
2020-04-18 08:01:36 +02:00
|
|
|
climate_api.register_influence("biome", function(pos)
|
|
|
|
local data = minetest.get_biome_data(pos)
|
|
|
|
local biome = minetest.get_biome_name(data.biome)
|
|
|
|
return biome
|
|
|
|
end)
|
|
|
|
|
2020-05-13 16:03:28 +02:00
|
|
|
climate_api.register_influence("windspeed", function(pos)
|
|
|
|
local wind = climate_api.environment.get_wind(pos)
|
2020-04-18 11:12:47 +02:00
|
|
|
return vector.length(wind)
|
2020-04-14 11:25:00 +02:00
|
|
|
end)
|
|
|
|
|
2020-04-25 15:49:53 +02:00
|
|
|
climate_api.register_global_influence("wind_yaw", function()
|
2020-05-13 16:03:28 +02:00
|
|
|
local wind = climate_api.environment.get_wind({x = 0, y = 0, z = 0})
|
2020-04-18 11:12:47 +02:00
|
|
|
if vector.length(wind) == 0 then return 0 end
|
|
|
|
return minetest.dir_to_yaw(wind)
|
2020-04-14 11:25:00 +02:00
|
|
|
end)
|
|
|
|
|
2020-04-18 08:01:36 +02:00
|
|
|
climate_api.register_influence("height", function(pos)
|
|
|
|
return pos.y
|
|
|
|
end)
|
|
|
|
|
|
|
|
climate_api.register_influence("light", function(pos)
|
2020-04-22 00:56:34 +02:00
|
|
|
pos = vector.add(pos, {x = 0, y = 1, z = 0})
|
2020-05-29 21:52:45 +02:00
|
|
|
return minetest.get_node_light(pos) or 0
|
2020-04-18 08:01:36 +02:00
|
|
|
end)
|
|
|
|
|
|
|
|
climate_api.register_influence("daylight", function(pos)
|
2020-04-22 00:56:34 +02:00
|
|
|
pos = vector.add(pos, {x = 0, y = 1, z = 0})
|
2023-02-22 05:21:52 +01:00
|
|
|
return minetest.get_natural_light(pos, 0.5) or 0
|
2020-04-14 11:25:00 +02:00
|
|
|
end)
|
|
|
|
|
2020-10-08 22:02:38 +02:00
|
|
|
climate_api.register_influence("indoors", function(pos)
|
|
|
|
pos = vector.add(pos, {x = 0, y = 1, z = 0})
|
2023-02-22 05:21:52 +01:00
|
|
|
local daylight = minetest.get_natural_light(pos, 0.5) or 0
|
|
|
|
-- max light is 15 but allow adjacent nodes to still be outdoors
|
|
|
|
-- to reduce effect switching on and off when walking underneath single nodes
|
|
|
|
if daylight < 14 then return true end
|
2020-10-08 22:02:38 +02:00
|
|
|
|
|
|
|
for i = 1, climate_mod.settings.ceiling_checks do
|
|
|
|
local lpos = vector.add(pos, {x = 0, y = i, z = 0})
|
|
|
|
local node = minetest.get_node_or_nil(lpos)
|
|
|
|
if node ~= nil and node.name ~= "air" and node.name ~= "ignore" then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end)
|
|
|
|
|
2020-05-12 16:00:24 +02:00
|
|
|
climate_api.register_global_influence("time",
|
2020-05-16 16:19:28 +02:00
|
|
|
minetest.get_timeofday
|
2020-05-12 16:00:24 +02:00
|
|
|
)
|