mirror of
https://github.com/t-affeldt/climate_api.git
synced 2024-12-22 08:50:37 +01:00
Add chat commands for forcing weather presets
This commit is contained in:
parent
299d520af6
commit
f42f8481da
20
TODO.md
20
TODO.md
@ -1,19 +1,23 @@
|
||||
# TODO
|
||||
|
||||
## Required for MVP
|
||||
- Test non-random heat and humidity values
|
||||
- Find good values for weather conditions
|
||||
- Make sure all weather presets are working
|
||||
- Add light level to possible conditions
|
||||
|
||||
## Required for Beta
|
||||
- Implement fallback for sky changes without skylayer
|
||||
- Ability to register environment conditions dynamically (like the heat)
|
||||
- Implement ABM system for additional effects
|
||||
- Implement snow layers, puddles, soil hydration, fire extinguishing
|
||||
|
||||
## Planned for first release
|
||||
- Improve test_condition function
|
||||
- Implement ABM system for additional effects
|
||||
- Add light level to possible conditions
|
||||
- Implement fallback for sky changes without skylayer
|
||||
- Write helpful README
|
||||
- Find good values for weather conditions
|
||||
- Set effects on player join
|
||||
- Improve value structures of particle and skybox effects
|
||||
- Make sounds adjust to changes by weather presets
|
||||
- Ability to force set a wind speed via chat commands
|
||||
|
||||
## Nice to have
|
||||
- Write documentation on how to add weathers and effects
|
||||
@ -23,10 +27,9 @@
|
||||
- Optimize performance by replacing some particles with animated texture planes
|
||||
- Make switches between effects more smooth
|
||||
- Adjust size of particle boxes based on player speed
|
||||
- Ability to register environment conditions dynamically (like the heat)
|
||||
- Create conditions for time of day, annual progression, biome filters
|
||||
- Let rain extinguish flames
|
||||
- Ability to force toggle weather presets on / off with chat commands
|
||||
- Fork lightning so that it uses skylayer
|
||||
- Support for sail boats mod
|
||||
|
||||
## Future Plans & Ideas
|
||||
- Complete season system
|
||||
@ -35,6 +38,7 @@
|
||||
- holidays and reminders via chat commands
|
||||
- day/night cycle adjusted to season
|
||||
- special events like a bloodmoon -> increased mob spawns
|
||||
- water can freeze over in winter
|
||||
- Fantasy weather effects
|
||||
- pretty skyboxes
|
||||
- swirling flower petals, mushroom spores, etc. in fitting biomes
|
||||
|
5
init.lua
5
init.lua
@ -33,12 +33,13 @@ climate_mod.settings = {
|
||||
}
|
||||
|
||||
-- initiate empty registers
|
||||
climate_mod.current_weather = {}
|
||||
climate_mod.current_effects = {}
|
||||
climate_mod.weathers = {}
|
||||
climate_mod.effects = {}
|
||||
climate_mod.cycles = {}
|
||||
climate_mod.influences = {}
|
||||
climate_mod.current_weather = {}
|
||||
climate_mod.current_effects = {}
|
||||
climate_mod.forced_weather = {}
|
||||
|
||||
-- import core API
|
||||
climate_mod.state = dofile(modpath .. "/lib/datastorage.lua")
|
||||
|
@ -79,11 +79,54 @@ minetest.register_chatcommand("set_humidity", {
|
||||
|
||||
minetest.register_chatcommand("weather_settings", {
|
||||
description = "Print the active Climate API configuration",
|
||||
privs = { weather = true },
|
||||
func = function(playername)
|
||||
minetest.chat_send_player(playername, "Current Settings\n================")
|
||||
for setting, value in pairs(climate_mod.settings) do
|
||||
minetest.chat_send_player(playername, dump2(value, setting))
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("set_weather", {
|
||||
params ="<weather> <status>",
|
||||
description ="Turn the specified weather preset on or off for all players or reset it to automatic",
|
||||
privs = { weather = true },
|
||||
func = function(playername, param)
|
||||
local arguments = {}
|
||||
for w in param:gmatch("%S+") do table.insert(arguments, w) end
|
||||
local weather = arguments[1]
|
||||
if climate_mod.weathers[weather] == nil then
|
||||
minetest.chat_send_player(playername, "Unknown weather preset")
|
||||
return
|
||||
end
|
||||
local status
|
||||
if arguments[2] == "on" then
|
||||
status = true
|
||||
elseif arguments[2] == "off" then
|
||||
status = false
|
||||
elseif arguments[2] == "auto" then
|
||||
status = nil
|
||||
else
|
||||
minetest.chat_send_player(playername, "Invalid weather status. Set the preset to either on, off or auto.")
|
||||
return
|
||||
end
|
||||
climate_mod.forced_weather[weather] = status
|
||||
minetest.chat_send_player(playername, "Weather " .. weather .. " successfully set to " .. arguments[2])
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("weather_status", {
|
||||
description = "Prints which weather presets are enforced or disabled",
|
||||
func = function(playername)
|
||||
minetest.chat_send_player(playername, "Current activation rules:\n================")
|
||||
for weather, _ in pairs(climate_mod.weathers) do
|
||||
local status = "auto"
|
||||
if climate_mod.forced_weather[weather] == true then
|
||||
status = "on"
|
||||
elseif climate_mod.forced_weather[weather] == false then
|
||||
status = "off"
|
||||
end
|
||||
minetest.chat_send_player(playername, dump2(status, weather))
|
||||
end
|
||||
end
|
||||
})
|
@ -30,11 +30,15 @@ local function test_condition(condition, env, goal)
|
||||
end
|
||||
end
|
||||
|
||||
local function is_weather_active(player, weather_config, env)
|
||||
if type(weather_config.conditions) == "function" then
|
||||
return weather_config.conditions(env)
|
||||
local function is_weather_active(player, weather, env)
|
||||
if climate_mod.forced_weather[weather] ~= nil then
|
||||
return climate_mod.forced_weather[weather]
|
||||
end
|
||||
for condition, goal in pairs(weather_config.conditions) do
|
||||
local config = climate_mod.weathers[weather]
|
||||
if type(config.conditions) == "function" then
|
||||
return config.conditions(env)
|
||||
end
|
||||
for condition, goal in pairs(config.conditions) do
|
||||
if not test_condition(condition, env, goal) then
|
||||
return false
|
||||
end
|
||||
@ -70,7 +74,7 @@ function trigger.get_active_effects()
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
local pname = player:get_player_name()
|
||||
local env = environments[pname]
|
||||
if is_weather_active(player, wconfig, env) then
|
||||
if is_weather_active(player, wname, env) then
|
||||
if type(climate_mod.current_weather[pname]) == "nil" then
|
||||
climate_mod.current_weather[pname] = {}
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user