influences.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. climate_api.register_influence("heat",
  2. climate_api.environment.get_heat
  3. )
  4. climate_api.register_influence("base_heat",
  5. minetest.get_heat
  6. )
  7. climate_api.register_influence("humidity",
  8. climate_api.environment.get_humidity
  9. )
  10. climate_api.register_influence("base_humidity",
  11. minetest.get_humidity
  12. )
  13. -- see https://en.wikipedia.org/wiki/Dew_point#Simple_approximation
  14. climate_api.register_influence("dewpoint", function(pos)
  15. local heat = climate_api.environment.get_heat(pos)
  16. local humidity = climate_api.environment.get_humidity(pos)
  17. return heat - (9/25 * (100 - humidity))
  18. end)
  19. climate_api.register_influence("base_dewpoint", function(pos)
  20. local heat = minetest.get_heat(pos)
  21. local humidity = minetest.get_humidity(pos)
  22. return heat - (9/25 * (100 - humidity))
  23. end)
  24. climate_api.register_influence("biome", function(pos)
  25. local data = minetest.get_biome_data(pos)
  26. local biome = minetest.get_biome_name(data.biome)
  27. return biome
  28. end)
  29. climate_api.register_influence("windspeed", function(pos)
  30. local wind = climate_api.environment.get_wind(pos)
  31. return vector.length(wind)
  32. end)
  33. climate_api.register_global_influence("wind_yaw", function()
  34. local wind = climate_api.environment.get_wind({x = 0, y = 0, z = 0})
  35. if vector.length(wind) == 0 then return 0 end
  36. return minetest.dir_to_yaw(wind)
  37. end)
  38. climate_api.register_influence("height", function(pos)
  39. return pos.y
  40. end)
  41. climate_api.register_influence("light", function(pos)
  42. pos = vector.add(pos, {x = 0, y = 1, z = 0})
  43. return minetest.env:get_node_light(pos) or 0
  44. end)
  45. climate_api.register_influence("daylight", function(pos)
  46. pos = vector.add(pos, {x = 0, y = 1, z = 0})
  47. return minetest.env:get_node_light(pos, 0.5) or 0
  48. end)
  49. climate_api.register_global_influence("time",
  50. minetest.get_timeofday
  51. )