init.lua 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. -- warn about outdated Minetest versions
  2. assert(minetest.add_particlespawner, "[Climate API] This mod requires a more current version of Minetest")
  3. -- initialize global API interfaces
  4. climate_api = {}
  5. climate_mod = {}
  6. -- set mod path for file imports
  7. local modname = minetest.get_current_modname()
  8. local modpath = minetest.get_modpath(modname)
  9. -- retrieve boolean value from mod config
  10. local function get_setting_bool(name, default)
  11. local value = minetest.settings:get_bool("climate_api_" .. name)
  12. if type(value) == "nil" then value = default end
  13. return minetest.is_yes(value)
  14. end
  15. -- retrive numeric value from mod config
  16. local function get_setting_number(name, default)
  17. local value = minetest.settings:get("climate_api_" .. name)
  18. if type(value) == "nil" then value = default end
  19. return tonumber(value)
  20. end
  21. -- load settings from config file
  22. climate_mod.settings = {
  23. damage = get_setting_bool("damage", true),
  24. raycast = get_setting_bool("raycast", true),
  25. particles = get_setting_bool("particles", true),
  26. skybox = get_setting_bool("skybox", true),
  27. sound = get_setting_bool("sound", true),
  28. hud_overlay = get_setting_bool("hud_overlay", true),
  29. wind = get_setting_bool("wind", true),
  30. seasons = get_setting_bool("seasons", true),
  31. fahrenheit = get_setting_bool("fahrenheit", false),
  32. block_updates = get_setting_bool("block_updates", true),
  33. heat = get_setting_number("heat_base", 0),
  34. humidity = get_setting_number("humidity_base", 0),
  35. time_spread = get_setting_number("time_spread", 1),
  36. particle_count = get_setting_number("particle_count", 1),
  37. tick_speed = get_setting_number("tick_speed", 1),
  38. volume = get_setting_number("volume", 1)
  39. }
  40. -- initialize empty registers
  41. climate_mod.weathers = {}
  42. climate_mod.effects = {}
  43. climate_mod.cycles = {}
  44. climate_mod.global_environment = {}
  45. climate_mod.global_influences = {}
  46. climate_mod.influences = {}
  47. climate_mod.current_weather = {}
  48. climate_mod.current_effects = {}
  49. climate_mod.forced_weather = {}
  50. climate_mod.forced_enviroment = {}
  51. -- handle persistent mod storage
  52. climate_mod.state = dofile(modpath .. "/lib/datastorage.lua")
  53. -- import core API
  54. climate_api = dofile(modpath .. "/lib/api.lua")
  55. climate_api.utility = dofile(modpath .. "/lib/api_utility.lua")
  56. climate_api.skybox = dofile(modpath .. "/lib/skybox_merger.lua")
  57. climate_api.player_physics = dofile(modpath .. "/lib/player_physics.lua")
  58. climate_api.environment = dofile(modpath .. "/lib/environment.lua")
  59. climate_mod.world = dofile(modpath .. "/lib/world.lua")
  60. climate_mod.trigger = dofile(modpath .. "/lib/trigger.lua")
  61. -- start event loop and register chat commands
  62. dofile(modpath.."/lib/main.lua")
  63. dofile(modpath.."/lib/commands.lua")
  64. -- register environment influences
  65. dofile(modpath .. "/lib/influences.lua")
  66. -- import predefined environment effects
  67. dofile(modpath .. "/ca_effects/damage.lua")
  68. dofile(modpath .. "/ca_effects/hud_overlay.lua")
  69. dofile(modpath .. "/ca_effects/particles.lua")
  70. dofile(modpath .. "/ca_effects/skybox.lua")
  71. dofile(modpath .. "/ca_effects/sound.lua")