mirror of
https://github.com/t-affeldt/climate_api.git
synced 2024-12-22 17:00:36 +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
|
# TODO
|
||||||
|
|
||||||
## Required for MVP
|
## Required for MVP
|
||||||
- Test non-random heat and humidity values
|
- Find good values for weather conditions
|
||||||
- Make sure all weather presets are working
|
- 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
|
## Planned for first release
|
||||||
- Improve test_condition function
|
- 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
|
- Write helpful README
|
||||||
- Find good values for weather conditions
|
|
||||||
- Set effects on player join
|
- Set effects on player join
|
||||||
- Improve value structures of particle and skybox effects
|
- Improve value structures of particle and skybox effects
|
||||||
- Make sounds adjust to changes by weather presets
|
- Make sounds adjust to changes by weather presets
|
||||||
|
- Ability to force set a wind speed via chat commands
|
||||||
|
|
||||||
## Nice to have
|
## Nice to have
|
||||||
- Write documentation on how to add weathers and effects
|
- Write documentation on how to add weathers and effects
|
||||||
@ -23,10 +27,9 @@
|
|||||||
- Optimize performance by replacing some particles with animated texture planes
|
- Optimize performance by replacing some particles with animated texture planes
|
||||||
- Make switches between effects more smooth
|
- Make switches between effects more smooth
|
||||||
- Adjust size of particle boxes based on player speed
|
- 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
|
- Create conditions for time of day, annual progression, biome filters
|
||||||
- Let rain extinguish flames
|
- Fork lightning so that it uses skylayer
|
||||||
- Ability to force toggle weather presets on / off with chat commands
|
- Support for sail boats mod
|
||||||
|
|
||||||
## Future Plans & Ideas
|
## Future Plans & Ideas
|
||||||
- Complete season system
|
- Complete season system
|
||||||
@ -35,6 +38,7 @@
|
|||||||
- holidays and reminders via chat commands
|
- holidays and reminders via chat commands
|
||||||
- day/night cycle adjusted to season
|
- day/night cycle adjusted to season
|
||||||
- special events like a bloodmoon -> increased mob spawns
|
- special events like a bloodmoon -> increased mob spawns
|
||||||
|
- water can freeze over in winter
|
||||||
- Fantasy weather effects
|
- Fantasy weather effects
|
||||||
- pretty skyboxes
|
- pretty skyboxes
|
||||||
- swirling flower petals, mushroom spores, etc. in fitting biomes
|
- 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
|
-- initiate empty registers
|
||||||
climate_mod.current_weather = {}
|
|
||||||
climate_mod.current_effects = {}
|
|
||||||
climate_mod.weathers = {}
|
climate_mod.weathers = {}
|
||||||
climate_mod.effects = {}
|
climate_mod.effects = {}
|
||||||
climate_mod.cycles = {}
|
climate_mod.cycles = {}
|
||||||
climate_mod.influences = {}
|
climate_mod.influences = {}
|
||||||
|
climate_mod.current_weather = {}
|
||||||
|
climate_mod.current_effects = {}
|
||||||
|
climate_mod.forced_weather = {}
|
||||||
|
|
||||||
-- import core API
|
-- import core API
|
||||||
climate_mod.state = dofile(modpath .. "/lib/datastorage.lua")
|
climate_mod.state = dofile(modpath .. "/lib/datastorage.lua")
|
||||||
|
@ -79,7 +79,6 @@ minetest.register_chatcommand("set_humidity", {
|
|||||||
|
|
||||||
minetest.register_chatcommand("weather_settings", {
|
minetest.register_chatcommand("weather_settings", {
|
||||||
description = "Print the active Climate API configuration",
|
description = "Print the active Climate API configuration",
|
||||||
privs = { weather = true },
|
|
||||||
func = function(playername)
|
func = function(playername)
|
||||||
minetest.chat_send_player(playername, "Current Settings\n================")
|
minetest.chat_send_player(playername, "Current Settings\n================")
|
||||||
for setting, value in pairs(climate_mod.settings) do
|
for setting, value in pairs(climate_mod.settings) do
|
||||||
@ -87,3 +86,47 @@ minetest.register_chatcommand("weather_settings", {
|
|||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
||||||
local function is_weather_active(player, weather_config, env)
|
local function is_weather_active(player, weather, env)
|
||||||
if type(weather_config.conditions) == "function" then
|
if climate_mod.forced_weather[weather] ~= nil then
|
||||||
return weather_config.conditions(env)
|
return climate_mod.forced_weather[weather]
|
||||||
end
|
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
|
if not test_condition(condition, env, goal) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -70,7 +74,7 @@ function trigger.get_active_effects()
|
|||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
local env = environments[pname]
|
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
|
if type(climate_mod.current_weather[pname]) == "nil" then
|
||||||
climate_mod.current_weather[pname] = {}
|
climate_mod.current_weather[pname] = {}
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user