From 8076994db98a30b1cda751c3bbcf13af8e6d6cb6 Mon Sep 17 00:00:00 2001 From: zaoqi Date: Wed, 1 Jan 2020 18:57:00 +0800 Subject: [PATCH] fix --- api.lua | 38 +++++++++++++++++++------------------- init.lua | 1 + 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/api.lua b/api.lua index 644488c..33a7407 100644 --- a/api.lua +++ b/api.lua @@ -617,36 +617,36 @@ function vehicles.object_drive(entity, dtime, def) end -function vehicles.object_glide(entity, dtime, speed, decell, gravity, moving_anim, stand_anim) - if entity.driver == nil or entity.driver:get_player_name() == "" then - entity.object:remove() +function vehicles.object_glide(self, dtime, speed, decell, gravity, moving_anim, stand_anim) + if self.driver == nil or self.driver:get_player_name() == "" then + self.object:remove() return else - local b1, b2 = pcall(function() return entity.driver:get_attach():get_luaentity() == self end) + local b1, b2 = pcall(function() return self.driver:get_attach():get_luaentity() == self end) if not (b1 and b2) then - pcall(force_detach, entity.driver) - entity.object:remove() + pcall(force_detach, self.driver) + self.object:remove() return end end - local ctrl = entity.driver:get_player_control() - local dir = entity.driver:get_look_dir() - local velo = entity.object:getvelocity() + local ctrl = self.driver:get_player_control() + local dir = self.driver:get_look_dir() + local velo = self.object:getvelocity() local vec_glide = {x=dir.x*speed*decell, y=velo.y, z=dir.z*speed*decell} - local yaw = entity.driver:get_look_yaw() + local yaw = self.driver:get_look_yaw() if not ctrl.sneak then - entity.object:setyaw(yaw+math.pi+math.pi/2) - entity.object:setvelocity(vec_glide) - entity.object:setacceleration({x=0, y=gravity, z=0}) + self.object:setyaw(yaw+math.pi+math.pi/2) + self.object:setvelocity(vec_glide) + self.object:setacceleration({x=0, y=gravity, z=0}) end if ctrl.sneak then local vec = {x=0,y=gravity*15,z=0} - local yaw = entity.driver:get_look_yaw() - entity.object:setyaw(yaw+math.pi+math.pi/2) - entity.object:setvelocity(vec) + local yaw = self.driver:get_look_yaw() + self.object:setyaw(yaw+math.pi+math.pi/2) + self.object:setvelocity(vec) end if velo.y == 0 then - local pos = entity.object:getpos() + local pos = self.object:getpos() for dx=-1,1 do for dy=-1,1 do for dz=-1,1 do @@ -654,8 +654,8 @@ function vehicles.object_glide(entity, dtime, speed, decell, gravity, moving_ani local t = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz} local n = minetest.env:get_node(p).name if n ~= "massdestruct:parachute" and n ~= "air" then - local pos = entity.object:getpos() - entity.object:remove() + local pos = self.object:getpos() + self.object:remove() return end end diff --git a/init.lua b/init.lua index ca86317..5e166b0 100644 --- a/init.lua +++ b/init.lua @@ -1738,6 +1738,7 @@ minetest.register_entity("vehicles:parachute", { vehicles.object_glide(self, dtime, 8, 0.92, -0.2, "", "") return false end + self.object:remove() return true end, })