Skip to content

Commit

Permalink
Merge pull request #7 from TheTermos/dev
Browse files Browse the repository at this point in the history
Fix potential crash caused by spontaneous detach
  • Loading branch information
TheTermos committed Jan 10, 2021
2 parents 174f39f + 51d94f2 commit 4c7f5bc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions init.lua
Expand Up @@ -89,7 +89,10 @@ local sailstep = function(self)

-- local dtime = min(self.dtime,0.5)
local accel_y = self.object:get_acceleration().y
if self.mast then
if not self.mast then return end
local _,_,spos,sailrot = self.mast:get_attach()

if sailrot then
local wind = get_wind()
local vel = self.object:get_velocity()
wind = {x=wind.x - vel.x,y=0,z=wind.z-vel.z}
Expand All @@ -111,7 +114,7 @@ local sailstep = function(self)
local accel = vct.add(longit_drag,later_drag)
local rudder_angle = self.rudder_angle

local _,_,spos,sailrot = self.mast:get_attach()
-- local _,_,spos,sailrot = self.mast:get_attach()

-- player control
if self.driver then
Expand Down

0 comments on commit 4c7f5bc

Please sign in to comment.