1
0
mirror of https://github.com/t-affeldt/regional_weather.git synced 2025-01-09 01:30:28 +01:00
regional_weather/ca_effects/damage.lua
2020-04-16 19:13:14 +02:00

17 lines
520 B
Lua

if not regional_weather.settings.damage then return end
local EFFECT_NAME = "regional_weather:damage"
local function handle_effect(player_data)
for playername, data in pairs(player_data) do
local player = minetest.get_player_by_name(playername)
local hp = player:get_hp()
for weather, value in pairs(data) do
hp = hp - value
end
player:set_hp(hp, "weather damage")
end
end
climate_api.register_effect(EFFECT_NAME, handle_effect, "tick")
climate_api.set_effect_cycle(EFFECT_NAME, climate_api.LONG_CYCLE)