Fix crash in boats mod

This commit is contained in:
sfan5 2014-07-06 09:53:54 +02:00 committed by BlockMen
parent 7e5dc6c374
commit 46b6cee1fc

@ -36,7 +36,7 @@ local boat = {
visual = "mesh", visual = "mesh",
mesh = "boat.x", mesh = "boat.x",
textures = {"default_wood.png"}, textures = {"default_wood.png"},
driver = nil, driver = nil,
v = 0, v = 0,
last_v = 0, last_v = 0,
@ -76,6 +76,7 @@ function boat:get_staticdata()
end end
function boat:on_punch(puncher, time_from_last_punch, tool_capabilities, direction) function boat:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
puncher:set_detach()
self.object:remove() self.object:remove()
if puncher and puncher:is_player() and not minetest.setting_getbool("creative_mode") then if puncher and puncher:is_player() and not minetest.setting_getbool("creative_mode") then
puncher:get_inventory():add_item("main", "boats:boat") puncher:get_inventory():add_item("main", "boats:boat")
@ -94,14 +95,14 @@ function boat:on_step(dtime)
self.v = self.v-0.08 self.v = self.v-0.08
end end
if ctrl.left then if ctrl.left then
if ctrl.down then if ctrl.down then
self.object:setyaw(yaw-math.pi/120-dtime*math.pi/120) self.object:setyaw(yaw-math.pi/120-dtime*math.pi/120)
else else
self.object:setyaw(yaw+math.pi/120+dtime*math.pi/120) self.object:setyaw(yaw+math.pi/120+dtime*math.pi/120)
end end
end end
if ctrl.right then if ctrl.right then
if ctrl.down then if ctrl.down then
self.object:setyaw(yaw+math.pi/120+dtime*math.pi/120) self.object:setyaw(yaw+math.pi/120+dtime*math.pi/120)
else else
self.object:setyaw(yaw-math.pi/120-dtime*math.pi/120) self.object:setyaw(yaw-math.pi/120-dtime*math.pi/120)
@ -122,7 +123,7 @@ function boat:on_step(dtime)
if math.abs(self.v) > 4.5 then if math.abs(self.v) > 4.5 then
self.v = 4.5*get_sign(self.v) self.v = 4.5*get_sign(self.v)
end end
local p = self.object:getpos() local p = self.object:getpos()
p.y = p.y-0.5 p.y = p.y-0.5
local new_velo = {x=0,y=0,z=0} local new_velo = {x=0,y=0,z=0}
@ -170,7 +171,7 @@ minetest.register_craftitem("boats:boat", {
wield_image = "boat_wield.png", wield_image = "boat_wield.png",
wield_scale = {x=2, y=2, z=1}, wield_scale = {x=2, y=2, z=1},
liquids_pointable = true, liquids_pointable = true,
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then if pointed_thing.type ~= "node" then
return return