Boats: Check player attached object
authorRui914 <mrrst0914@gmail.com>
Wed, 28 Oct 2015 15:41:15 +0000 (00:41 +0900)
committerparamat <mat.gregory@virginmedia.com>
Thu, 29 Oct 2015 23:06:01 +0000 (23:06 +0000)
mods/boats/init.lua

index e17d8b1b78addbbb777b2316ba966e417d00248a..a7e62e43da9ca1d9b3096f95ca9de2e3b872ac7a 100644 (file)
@@ -62,6 +62,14 @@ function boat.on_rightclick(self, clicker)
                        clicker:setpos(pos)
                end)
        elseif not self.driver then
+               local attach = clicker:get_attach()
+               if attach and attach:get_luaentity() then
+                       local luaentity = attach:get_luaentity()
+                       if luaentity.driver then
+                               luaentity.driver = nil
+                       end
+                       clicker:set_detach()
+               end
                self.driver = clicker
                clicker:set_attach(self.object, "",
                        {x = 0, y = 11, z = -3}, {x = 0, y = 0, z = 0})
@@ -88,8 +96,7 @@ function boat.get_staticdata(self)
 end
 
 
-function boat.on_punch(self, puncher, time_from_last_punch,
-               tool_capabilities, direction)
+function boat.on_punch(self, puncher)
        if not puncher or not puncher:is_player() or self.removed then
                return
        end