2020-04-26 18:10:46 +02:00
|
|
|
--[[
|
|
|
|
# Player Speed Effect
|
|
|
|
Use this effect to modify a player's movement speed.
|
|
|
|
Expects a numeric value that will be multiplied with the current speed physics.
|
|
|
|
]]
|
|
|
|
|
2020-04-16 10:04:34 +02:00
|
|
|
local EFFECT_NAME = "regional_weather:speed_buff"
|
|
|
|
|
2020-04-13 01:58:27 +02:00
|
|
|
local function handle_effect(player_data)
|
2020-04-18 11:14:09 +02:00
|
|
|
for playername, data in pairs(player_data) do
|
2020-04-13 01:58:27 +02:00
|
|
|
local player = minetest.get_player_by_name(playername)
|
|
|
|
local product = 1
|
|
|
|
for weather, value in pairs(data) do
|
|
|
|
product = product * value
|
|
|
|
end
|
2020-05-12 16:01:13 +02:00
|
|
|
climate_api.player_physics.add(EFFECT_NAME, player, "speed", product)
|
2020-04-13 01:58:27 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function remove_effect(player_data)
|
|
|
|
for playername, data in ipairs(player_data) do
|
|
|
|
local player = minetest.get_player_by_name(playername)
|
2020-05-12 16:01:13 +02:00
|
|
|
climate_api.player_physics.remove(EFFECT_NAME, player, "speed")
|
2020-04-13 01:58:27 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-16 10:04:34 +02:00
|
|
|
climate_api.register_effect(EFFECT_NAME, handle_effect, "tick")
|
|
|
|
climate_api.register_effect(EFFECT_NAME, remove_effect, "stop")
|
|
|
|
climate_api.set_effect_cycle(EFFECT_NAME, climate_api.SHORT_CYCLE)
|