2020-04-26 18:11:38 +02:00
|
|
|
-- warn about outdated Minetest versions
|
2020-04-13 01:55:39 +02:00
|
|
|
assert(minetest.add_particlespawner, "[Climate API] This mod requires a more current version of Minetest")
|
2020-04-09 09:03:02 +02:00
|
|
|
|
2020-04-26 18:11:38 +02:00
|
|
|
-- initialize global API interfaces
|
2020-04-13 01:55:39 +02:00
|
|
|
climate_api = {}
|
|
|
|
climate_mod = {}
|
|
|
|
|
2020-04-26 18:11:38 +02:00
|
|
|
-- set mod path for file imports
|
2020-04-13 01:55:39 +02:00
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
local modpath = minetest.get_modpath(modname)
|
2020-04-09 09:03:02 +02:00
|
|
|
|
2020-04-26 18:11:38 +02:00
|
|
|
-- retrieve boolean value from mod config
|
2020-04-16 19:12:20 +02:00
|
|
|
local function get_setting_bool(name, default)
|
2020-04-14 05:44:46 +02:00
|
|
|
local value = minetest.settings:get_bool("climate_api_" .. name)
|
|
|
|
if type(value) == "nil" then value = default end
|
|
|
|
return minetest.is_yes(value)
|
2020-04-09 09:03:02 +02:00
|
|
|
end
|
|
|
|
|
2020-04-26 18:11:38 +02:00
|
|
|
-- retrive numeric value from mod config
|
2020-04-16 19:12:20 +02:00
|
|
|
local function get_setting_number(name, default)
|
2020-04-14 05:44:46 +02:00
|
|
|
local value = minetest.settings:get("climate_api_" .. name)
|
|
|
|
if type(value) == "nil" then value = default end
|
|
|
|
return tonumber(value)
|
2020-04-09 09:03:02 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- load settings from config file
|
2020-04-13 01:55:39 +02:00
|
|
|
climate_mod.settings = {
|
2023-02-23 04:33:17 +01:00
|
|
|
damage = get_setting_bool("damage", true),
|
|
|
|
raycast = get_setting_bool("raycast", true),
|
|
|
|
particles = get_setting_bool("particles", true),
|
|
|
|
skybox = get_setting_bool("skybox", true),
|
|
|
|
sound = get_setting_bool("sound", true),
|
|
|
|
hud_overlay = get_setting_bool("hud_overlay", true),
|
|
|
|
wind = get_setting_bool("wind", true),
|
|
|
|
seasons = get_setting_bool("seasons", true),
|
|
|
|
fahrenheit = get_setting_bool("fahrenheit", false),
|
|
|
|
block_updates = get_setting_bool("block_updates", true),
|
|
|
|
heat = get_setting_number("heat_base", 0),
|
|
|
|
humidity = get_setting_number("humidity_base", 0),
|
|
|
|
time_spread = get_setting_number("time_spread", 1),
|
|
|
|
particle_count = get_setting_number("particle_count", 1),
|
|
|
|
tick_speed = get_setting_number("tick_speed", 1),
|
|
|
|
volume = get_setting_number("volume", 1),
|
|
|
|
ceiling_checks = get_setting_number("ceiling_checks", 10)
|
2020-04-09 09:03:02 +02:00
|
|
|
}
|
|
|
|
|
2023-02-23 04:33:17 +01:00
|
|
|
-- warn about clouds being overriden by MTG weather
|
|
|
|
if climate_mod.settings.skybox and minetest.get_modpath("weather") and minetest.settings:get_bool("enable_weather") then
|
|
|
|
minetest.log("warning", "[Regional Weather] " ..
|
|
|
|
S("Disable MTG weather for the best experience. Check the forum for more information."))
|
|
|
|
minetest.settings:set_bool("enable_weather", false) -- try to disable MTG weather. may or may not work depending on load order
|
|
|
|
end
|
|
|
|
|
2020-05-29 21:52:45 +02:00
|
|
|
climate_mod.i18n = minetest.get_translator("climate_api")
|
|
|
|
|
2020-04-26 18:11:38 +02:00
|
|
|
-- initialize empty registers
|
2020-04-14 05:44:46 +02:00
|
|
|
climate_mod.weathers = {}
|
|
|
|
climate_mod.effects = {}
|
|
|
|
climate_mod.cycles = {}
|
2020-04-25 15:49:53 +02:00
|
|
|
climate_mod.global_environment = {}
|
|
|
|
climate_mod.global_influences = {}
|
2020-04-14 11:25:00 +02:00
|
|
|
climate_mod.influences = {}
|
2020-04-15 00:12:44 +02:00
|
|
|
climate_mod.current_weather = {}
|
|
|
|
climate_mod.current_effects = {}
|
|
|
|
climate_mod.forced_weather = {}
|
2020-05-13 16:03:28 +02:00
|
|
|
climate_mod.forced_enviroment = {}
|
2020-04-09 09:03:02 +02:00
|
|
|
|
2020-04-26 18:11:38 +02:00
|
|
|
-- handle persistent mod storage
|
2020-04-13 01:55:39 +02:00
|
|
|
climate_mod.state = dofile(modpath .. "/lib/datastorage.lua")
|
2020-04-26 18:11:38 +02:00
|
|
|
|
|
|
|
-- import core API
|
2020-04-13 01:55:39 +02:00
|
|
|
climate_api = dofile(modpath .. "/lib/api.lua")
|
|
|
|
climate_api.utility = dofile(modpath .. "/lib/api_utility.lua")
|
2020-04-24 01:35:07 +02:00
|
|
|
climate_api.skybox = dofile(modpath .. "/lib/skybox_merger.lua")
|
2020-05-12 16:00:24 +02:00
|
|
|
climate_api.player_physics = dofile(modpath .. "/lib/player_physics.lua")
|
2020-04-13 01:55:39 +02:00
|
|
|
climate_api.environment = dofile(modpath .. "/lib/environment.lua")
|
|
|
|
climate_mod.world = dofile(modpath .. "/lib/world.lua")
|
|
|
|
climate_mod.trigger = dofile(modpath .. "/lib/trigger.lua")
|
2020-04-26 18:11:38 +02:00
|
|
|
|
|
|
|
-- start event loop and register chat commands
|
2020-04-13 01:55:39 +02:00
|
|
|
dofile(modpath.."/lib/main.lua")
|
2020-04-14 05:44:46 +02:00
|
|
|
dofile(modpath.."/lib/commands.lua")
|
2020-04-13 01:55:39 +02:00
|
|
|
|
2020-04-26 18:11:38 +02:00
|
|
|
-- register environment influences
|
|
|
|
dofile(modpath .. "/lib/influences.lua")
|
|
|
|
|
2020-04-13 01:55:39 +02:00
|
|
|
-- import predefined environment effects
|
2020-04-28 01:22:27 +02:00
|
|
|
dofile(modpath .. "/ca_effects/damage.lua")
|
2020-04-16 08:05:16 +02:00
|
|
|
dofile(modpath .. "/ca_effects/hud_overlay.lua")
|
2020-04-13 01:55:39 +02:00
|
|
|
dofile(modpath .. "/ca_effects/particles.lua")
|
|
|
|
dofile(modpath .. "/ca_effects/skybox.lua")
|
2020-04-14 11:25:00 +02:00
|
|
|
dofile(modpath .. "/ca_effects/sound.lua")
|