Remove windows. Move driver back to envelope. Add cruise mode

This commit is contained in:
paramat 2018-06-11 07:53:58 +01:00
parent 33b28e472b
commit 0e0d6d1666
6 changed files with 28 additions and 17 deletions

View File

@ -1,4 +1,4 @@
airboat 0.1.1 by paramat airboat 0.1.2 by paramat
For Minetest 0.5.0dev (of 10/06/18) and later For Minetest 0.5.0dev (of 10/06/18) and later
Depends default Depends default

View File

@ -31,9 +31,10 @@ local airboat = {
textures = {"airboat:airboat_nodebox"}, textures = {"airboat:airboat_nodebox"},
driver = nil, driver = nil,
removed = false,
v = 0, v = 0,
vy = 0, vy = 0,
removed = false auto = false,
} }
@ -42,8 +43,10 @@ function airboat.on_rightclick(self, clicker)
return return
end end
local name = clicker:get_player_name() local name = clicker:get_player_name()
-- Detach
if self.driver and clicker == self.driver then if self.driver and clicker == self.driver then
self.driver = nil self.driver = nil
self.auto = false
clicker:set_detach() clicker:set_detach()
player_api.player_attached[name] = false player_api.player_attached[name] = false
player_api.set_animation(clicker, "stand" , 30) player_api.set_animation(clicker, "stand" , 30)
@ -51,6 +54,7 @@ function airboat.on_rightclick(self, clicker)
minetest.after(0.1, function() minetest.after(0.1, function()
clicker:setpos(pos) clicker:setpos(pos)
end) end)
-- Attach
elseif not self.driver then elseif not self.driver then
local attach = clicker:get_attach() local attach = clicker:get_attach()
if attach and attach:get_luaentity() then if attach and attach:get_luaentity() then
@ -62,7 +66,7 @@ function airboat.on_rightclick(self, clicker)
end end
self.driver = clicker self.driver = clicker
clicker:set_attach(self.object, "", clicker:set_attach(self.object, "",
{x = 0, y = -14.25, z = -1}, {x = 0, y = 0, z = 0}) {x = 0, y = -2, z = 0}, {x = 0, y = 0, z = 0})
player_api.player_attached[name] = true player_api.player_attached[name] = true
minetest.after(0.2, function() minetest.after(0.2, function()
player_api.set_animation(clicker, "sit" , 30) player_api.set_animation(clicker, "sit" , 30)
@ -97,7 +101,6 @@ function airboat.on_punch(self, puncher)
minetest.add_item(self.object:getpos(), leftover) minetest.add_item(self.object:getpos(), leftover)
end end
end end
-- Delay remove to ensure player is detached
minetest.after(0.1, function() minetest.after(0.1, function()
self.object:remove() self.object:remove()
end) end)
@ -109,24 +112,32 @@ function airboat.on_step(self, dtime)
self.v = get_v(self.object:getvelocity()) * get_sign(self.v) self.v = get_v(self.object:getvelocity()) * get_sign(self.v)
self.vy = self.object:getvelocity().y self.vy = self.object:getvelocity().y
if self.driver then if self.driver then
local ctrl = self.driver:get_player_control()
local yaw = self.object:getyaw() local yaw = self.object:getyaw()
if ctrl.up then local ctrl = self.driver:get_player_control()
self.v = self.v + 0.1 if ctrl.up and ctrl.down then
if not self.auto then
self.auto = true
end
elseif ctrl.down then elseif ctrl.down then
self.v = self.v - 0.1 self.v = self.v - 0.1
if self.auto then
self.auto = false
end
elseif ctrl.up or self.auto then
self.v = self.v + 0.1
end end
if ctrl.left then if ctrl.left then
self.object:setyaw(yaw + (1 + dtime) * 0.02) self.object:setyaw(yaw + (1 + dtime) * 0.015)
elseif ctrl.right then elseif ctrl.right then
self.object:setyaw(yaw - (1 + dtime) * 0.02) self.object:setyaw(yaw - (1 + dtime) * 0.015)
end end
if ctrl.jump then if ctrl.jump then
self.vy = self.vy + 0.1 self.vy = self.vy + 0.075
elseif ctrl.sneak then elseif ctrl.sneak then
self.vy = self.vy - 0.1 self.vy = self.vy - 0.075
end end
end end
if self.v == 0 and self.vy == 0 then if self.v == 0 and self.vy == 0 then
self.object:setpos(self.object:getpos()) self.object:setpos(self.object:getpos())
return return
@ -225,12 +236,12 @@ minetest.register_node("airboat:airboat_nodebox", {
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { -- widmin heimin lenmin widmax heimax lenmax fixed = { -- widmin heimin lenmin widmax heimax lenmax
{-0.271, -0.167, -0.5, 0.271, 0.375, 0.5}, -- Envelope {-0.271, -0.167, -0.5, 0.271, 0.375, 0.5}, -- Envelope
{-0.167, -0.5, -0.25, 0.167, -0.167, 0.25}, -- Gondola {-0.167, -0.5, -0.25, 0.167, -0.167, 0.25}, -- Gondola
{-0.021, 0.375, -0.5, 0.021, 0.5, -0.25}, -- Top fin {-0.021, 0.375, -0.5, 0.021, 0.5, -0.25}, -- Top fin
{-0.021, -0.292, -0.5, 0.021, -0.167, -0.25}, -- Base fin {-0.021, -0.292, -0.5, 0.021, -0.167, -0.25}, -- Base fin
{-0.396, 0.083, -0.5, -0.271, 0.125, -0.25}, -- Left fin {-0.396, 0.083, -0.5, -0.271, 0.125, -0.25}, -- Left fin
{0.271, 0.083, -0.5, 0.396, 0.125, -0.25}, -- Right fin { 0.271, 0.083, -0.5, 0.396, 0.125, -0.25}, -- Right fin
}, },
}, },
groups = {not_in_creative_inventory = 1}, groups = {not_in_creative_inventory = 1},

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 B

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 B

After

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 B

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 B

After

Width:  |  Height:  |  Size: 112 B