Optimize code and modernize API calls

* Remove is_connected() and use minetest counterpart

* Less calls to minetest.get_connected_players()

* Deprecated: get_player_velocity

* Luacheck: unused assignements

* Luacheck: unused variable

* Luacheck: already declared variable

---------

Co-authored-by: mazes 80 <>
This commit is contained in:
mazes-80
2023-02-22 03:10:33 +01:00
committed by GitHub
parent a56116e8ab
commit 59bf43aa28
6 changed files with 16 additions and 33 deletions

View File

@ -43,7 +43,7 @@ local function check_hit(player, ray)
)
origin = vector.add(origin, windpos)
end
local ray = minetest.raycast(origin, ppos)
ray = minetest.raycast(origin, ppos)
local obj = ray:next()
-- found nothing
if obj == nil then return false end

View File

@ -165,7 +165,7 @@ local function parse_config(player, particles)
-- correct spawn coordinates to adjust for player movement
if config.adjust_for_velocity then
local velocity = player:get_player_velocity()
local velocity = player:get_velocity()
config.minpos = vector.add(config.minpos, velocity)
config.maxpos = vector.add(config.maxpos, velocity)
end
@ -212,4 +212,4 @@ local function handle_effect(player_data)
end
climate_api.register_effect(EFFECT_NAME, handle_effect, "tick")
climate_api.set_effect_cycle(EFFECT_NAME, CYCLE_LENGTH)
climate_api.set_effect_cycle(EFFECT_NAME, CYCLE_LENGTH)