Skip to content

Commit

Permalink
avoid using core.get_player_by_name on every step
Browse files Browse the repository at this point in the history
also has the nice side-effect of making code less bulky
  • Loading branch information
SwissalpS committed Apr 18, 2024
1 parent 9b9c1ef commit 1ef2d61
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -336,18 +336,14 @@ local function get_pitch_lift(y)
end

local on_step = function(self, dtime, moveresult)
local driver = minetest.get_player_by_name(self.driver)
local driver = self.object:get_children()[1]
if not driver then
-- driver logged off
-- driver logged off or dead
self.object:remove()
return
end

if not driver:get_attach() then
-- driver died
self.object:remove()
return
elseif not glider.allow_hangglider_while_gliding then
if not glider.allow_hangglider_while_gliding then
local luaent
for _, obj in ipairs(driver:get_children()) do
luaent = obj:get_luaentity()
Expand Down

0 comments on commit 1ef2d61

Please sign in to comment.