mirror of
https://github.com/t-affeldt/regional_weather.git
synced 2025-07-21 09:55:29 +02:00
Separate weathers from engine
This commit is contained in:
0
ca_effects/damage.lua
Normal file
0
ca_effects/damage.lua
Normal file
18
ca_effects/lightning.lua
Normal file
18
ca_effects/lightning.lua
Normal file
@ -0,0 +1,18 @@
|
||||
if not minetest.get_modpath("lightning") then return end
|
||||
|
||||
local LIGHTNING_CHANCE = 10
|
||||
lightning.auto = false
|
||||
|
||||
local function handle_effect(player_data)
|
||||
for playername, data in pairs(player_data) do
|
||||
local player = minetest.get_player_by_name(playername)
|
||||
local ppos = player:get_pos()
|
||||
local random = rng:next(1, LIGHTNING_CHANCE)
|
||||
if random == 1 then
|
||||
lightning.strike(ppos)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
climate_api.register_effect("regional_weather:lightning", handle_effect, "tick")
|
||||
climate_api.set_effect_cycle("regional_weather:lightning", climate_api.LONG_CYCLE)
|
0
ca_effects/puddles.lua
Normal file
0
ca_effects/puddles.lua
Normal file
0
ca_effects/snow_layers.lua
Normal file
0
ca_effects/snow_layers.lua
Normal file
0
ca_effects/soil.lua
Normal file
0
ca_effects/soil.lua
Normal file
21
ca_effects/speed_buff.lua
Normal file
21
ca_effects/speed_buff.lua
Normal file
@ -0,0 +1,21 @@
|
||||
local function handle_effect(player_data)
|
||||
for playername, data in ipairs(player_data) do
|
||||
local player = minetest.get_player_by_name(playername)
|
||||
local product = 1
|
||||
for weather, value in pairs(data) do
|
||||
product = product * value
|
||||
end
|
||||
climate_api.utility.add_physics("regional_weather:speed_buff", player, "speed", product)
|
||||
end
|
||||
end
|
||||
|
||||
local function remove_effect(player_data)
|
||||
for playername, data in ipairs(player_data) do
|
||||
local player = minetest.get_player_by_name(playername)
|
||||
climate_api.utility.remove_physics("regional_weather:speed_buff", player, "speed")
|
||||
end
|
||||
end
|
||||
|
||||
climate_api.register_effect("regional_weather:speed_buff", handle_effect, "tick")
|
||||
climate_api.register_effect("regional_weather:speed_buff", remove_effect, "end")
|
||||
climate_api.set_effect_cycle("regional_weather:speed_buff", climate_api.SHORT_CYCLE)
|
Reference in New Issue
Block a user