Add windows. Move driver into gondola. Detect liquids not water
@ -1,4 +1,4 @@
|
|||||||
airboat 0.1.0 by paramat
|
airboat 0.1.1 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
|
||||||
|
|
||||||
|
37
init.lua
@ -1,8 +1,4 @@
|
|||||||
local function is_water(pos)
|
-- Functions
|
||||||
local nn = minetest.get_node(pos).name
|
|
||||||
return minetest.get_item_group(nn, "water") ~= 0
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function get_sign(i)
|
local function get_sign(i)
|
||||||
if i == 0 then
|
if i == 0 then
|
||||||
@ -25,6 +21,8 @@ local function get_v(v)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Airboat entity
|
||||||
|
|
||||||
local airboat = {
|
local airboat = {
|
||||||
physical = true,
|
physical = true,
|
||||||
collisionbox = {-0.85, -1.5, -0.85, 0.85, 1.5, 0.85},
|
collisionbox = {-0.85, -1.5, -0.85, 0.85, 1.5, 0.85},
|
||||||
@ -64,7 +62,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 = -1, z = 0}, {x = 0, y = 0, z = 0})
|
{x = 0, y = -14.25, z = -1}, {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)
|
||||||
@ -124,14 +122,12 @@ function airboat.on_step(self, dtime)
|
|||||||
self.object:setyaw(yaw - (1 + dtime) * 0.02)
|
self.object:setyaw(yaw - (1 + dtime) * 0.02)
|
||||||
end
|
end
|
||||||
if ctrl.jump then
|
if ctrl.jump then
|
||||||
self.vy = self.vy + 0.075
|
self.vy = self.vy + 0.1
|
||||||
elseif ctrl.sneak then
|
elseif ctrl.sneak then
|
||||||
self.vy = self.vy - 0.075
|
self.vy = self.vy - 0.1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local velo = self.object:getvelocity()
|
if self.v == 0 and self.vy == 0 then
|
||||||
if self.v == 0 and self.vy == 0 and
|
|
||||||
velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
|
||||||
self.object:setpos(self.object:getpos())
|
self.object:setpos(self.object:getpos())
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -146,7 +142,7 @@ function airboat.on_step(self, dtime)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local sy = get_sign(self.vy)
|
local sy = get_sign(self.vy)
|
||||||
self.vy = self.vy - 0.04 * sy
|
self.vy = self.vy - 0.03 * sy
|
||||||
if sy ~= get_sign(self.vy) then
|
if sy ~= get_sign(self.vy) then
|
||||||
self.vy = 0
|
self.vy = 0
|
||||||
end
|
end
|
||||||
@ -157,8 +153,9 @@ function airboat.on_step(self, dtime)
|
|||||||
local new_acce = {x = 0, y = 0, z = 0}
|
local new_acce = {x = 0, y = 0, z = 0}
|
||||||
local p = self.object:getpos()
|
local p = self.object:getpos()
|
||||||
p.y = p.y - 1.5
|
p.y = p.y - 1.5
|
||||||
if is_water(p) then
|
local def = minetest.registered_nodes[minetest.get_node(p).name]
|
||||||
new_acce = {x = 0, y = 20, z = 0}
|
if def and (def.liquidtype == "source" or def.liquidtype == "flowing") then
|
||||||
|
new_acce = {x = 0, y = 10, z = 0}
|
||||||
end
|
end
|
||||||
|
|
||||||
self.object:setpos(self.object:getpos())
|
self.object:setpos(self.object:getpos())
|
||||||
@ -171,12 +168,13 @@ end
|
|||||||
minetest.register_entity("airboat:airboat", airboat)
|
minetest.register_entity("airboat:airboat", airboat)
|
||||||
|
|
||||||
|
|
||||||
|
-- Craftitem
|
||||||
|
|
||||||
minetest.register_craftitem("airboat:airboat", {
|
minetest.register_craftitem("airboat:airboat", {
|
||||||
description = "Airboat",
|
description = "Airboat",
|
||||||
inventory_image = "airboat_airboat_inv.png",
|
inventory_image = "airboat_airboat_inv.png",
|
||||||
wield_scale = {x = 4, y = 4, z = 4},
|
wield_scale = {x = 4, y = 4, z = 4},
|
||||||
liquids_pointable = true,
|
liquids_pointable = true,
|
||||||
groups = {flammable = 2},
|
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
local under = pointed_thing.under
|
local under = pointed_thing.under
|
||||||
@ -193,10 +191,11 @@ minetest.register_craftitem("airboat:airboat", {
|
|||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
pointed_thing.under.y = pointed_thing.under.y + 2
|
pointed_thing.under.y = pointed_thing.under.y + 2
|
||||||
boat = minetest.add_entity(pointed_thing.under, "airboat:airboat")
|
local airboat = minetest.add_entity(pointed_thing.under,
|
||||||
if boat then
|
"airboat:airboat")
|
||||||
|
if airboat then
|
||||||
if placer then
|
if placer then
|
||||||
boat:setyaw(placer:get_look_horizontal())
|
airboat:setyaw(placer:get_look_horizontal())
|
||||||
end
|
end
|
||||||
local player_name = placer and placer:get_player_name() or ""
|
local player_name = placer and placer:get_player_name() or ""
|
||||||
if not (creative and creative.is_enabled_for and
|
if not (creative and creative.is_enabled_for and
|
||||||
@ -209,6 +208,8 @@ minetest.register_craftitem("airboat:airboat", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
-- Nodebox for entity wielditem visual
|
||||||
|
|
||||||
minetest.register_node("airboat:airboat_nodebox", {
|
minetest.register_node("airboat:airboat_nodebox", {
|
||||||
description = "Airboat Nodebox",
|
description = "Airboat Nodebox",
|
||||||
tiles = { -- top base right left front back
|
tiles = { -- top base right left front back
|
||||||
|
Before Width: | Height: | Size: 122 B After Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 146 B After Width: | Height: | Size: 149 B |
Before Width: | Height: | Size: 114 B After Width: | Height: | Size: 140 B |
Before Width: | Height: | Size: 112 B After Width: | Height: | Size: 139 B |