mirror of
https://gitlab.com/rautars/weather_pack.git
synced 2025-01-10 08:20:17 +01:00
add thunder weather (depends on sofar lightning mod)
This commit is contained in:
parent
92e76c85cc
commit
cbf280cffe
@ -1,10 +0,0 @@
|
||||
|
||||
|
||||
minetest.register_chatcommand("cw", {
|
||||
description = "normalize weather",
|
||||
privs = {rain_manager = true},
|
||||
func = function(name, param)
|
||||
weather.state = 'clear'
|
||||
save_weather()
|
||||
end
|
||||
})
|
@ -122,6 +122,10 @@ minetest.register_globalstep(function(dtime)
|
||||
return false
|
||||
end
|
||||
|
||||
rain.make_weather()
|
||||
end)
|
||||
|
||||
rain.make_weather = function()
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
if (is_underwater(player)) then
|
||||
return false
|
||||
@ -130,7 +134,7 @@ minetest.register_globalstep(function(dtime)
|
||||
rain.add_rain_particles(player, dtime)
|
||||
rain.update_sound(player)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
if weather.known_weathers.rain == nil then
|
||||
weather.known_weathers.rain = {
|
||||
|
3
thunder/depends.txt
Normal file
3
thunder/depends.txt
Normal file
@ -0,0 +1,3 @@
|
||||
weather_core
|
||||
rain
|
||||
lightning
|
35
thunder/init.lua
Normal file
35
thunder/init.lua
Normal file
@ -0,0 +1,35 @@
|
||||
-- turn off lightning mod 'auto mode'
|
||||
lightning.auto = false
|
||||
|
||||
thunder = {
|
||||
next_strike = 0,
|
||||
min_delay = 3,
|
||||
max_delay = 12,
|
||||
}
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
if weather.state ~= "thunder" then
|
||||
return false
|
||||
end
|
||||
|
||||
rain.make_weather()
|
||||
|
||||
if (thunder.next_strike <= os.time()) then
|
||||
lightning.strike()
|
||||
local delay = math.random(thunder.min_delay, thunder.max_delay)
|
||||
thunder.next_strike = os.time() + delay
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
thunder.clear = function()
|
||||
rain.clear()
|
||||
end
|
||||
|
||||
-- register thunderstorm weather
|
||||
if weather.known_weathers.thunder == nil then
|
||||
weather.known_weathers.thunder = {
|
||||
chance = 5,
|
||||
clear = thunder.clear
|
||||
}
|
||||
end
|
Loading…
Reference in New Issue
Block a user