Compare commits
5 Commits
68383b5ca7
...
1bd0e8706d
Author | SHA1 | Date |
---|---|---|
Alexsandro Percy | 1bd0e8706d | |
Alexsandro Percy | 9afb728d12 | |
Alexsandro Percy | 3e53421137 | |
Alexsandro Percy | f3af6866f2 | |
Alexsandro Percy | 91445b785f |
|
@ -16,7 +16,7 @@ function helicopter.vector_length_sq(v)
|
|||
end
|
||||
|
||||
if not minetest.global_exists("matrix3") then
|
||||
dofile(minetest.get_modpath("helicopter") .. DIR_DELIM .. "matrix.lua")
|
||||
dofile(minetest.get_modpath("nss_helicopter") .. DIR_DELIM .. "matrix.lua")
|
||||
end
|
||||
|
||||
function helicopter.check_node_below(obj)
|
||||
|
@ -166,7 +166,7 @@ function helicopter.heli_control(self, dtime, touching_ground, liquid_below, vel
|
|||
self.pointer:set_attach(self.object,'',{x=0,y=11.26,z=9.37},{x=0,y=0,z=energy_indicator_angle})
|
||||
else
|
||||
--in case it have lost the entity by some conflict
|
||||
self.pointer=minetest.add_entity({x=0,y=11.26,z=9.37},'helicopter:pointer')
|
||||
self.pointer=minetest.add_entity({x=0,y=11.26,z=9.37},"nss_helicopter:pointer")
|
||||
self.pointer:set_attach(self.object,'',{x=0,y=11.26,z=9.37},{x=0,y=0,z=energy_indicator_angle})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,17 +3,17 @@
|
|||
--
|
||||
|
||||
-- blades
|
||||
minetest.register_craftitem("helicopter:blades",{
|
||||
minetest.register_craftitem("nss_helicopter:blades",{
|
||||
description = "Helicopter Blades",
|
||||
inventory_image = "helicopter_blades_inv.png",
|
||||
})
|
||||
-- cabin
|
||||
minetest.register_craftitem("helicopter:cabin",{
|
||||
minetest.register_craftitem("nss_helicopter:cabin",{
|
||||
description = "Cabin for Helicopter",
|
||||
inventory_image = "helicopter_cabin_inv.png",
|
||||
})
|
||||
-- heli
|
||||
minetest.register_craftitem("helicopter:heli", {
|
||||
minetest.register_craftitem("nss_helicopter:heli", {
|
||||
description = "Helicopter",
|
||||
inventory_image = "helicopter_heli_inv.png",
|
||||
|
||||
|
@ -30,7 +30,7 @@ minetest.register_craftitem("helicopter:heli", {
|
|||
if color == "" then color = nil end
|
||||
local fuel = math.floor(imeta:get_float("fuel") * 100) / 100
|
||||
|
||||
local obj = minetest.add_entity(pointed_thing.above, "helicopter:heli")
|
||||
local obj = minetest.add_entity(pointed_thing.above, "nss_helicopter:heli")
|
||||
local ent = obj:get_luaentity()
|
||||
local owner = placer:get_player_name()
|
||||
ent.owner = owner
|
||||
|
@ -58,7 +58,7 @@ minetest.register_craftitem("helicopter:heli", {
|
|||
|
||||
if minetest.get_modpath("default") then
|
||||
minetest.register_craft({
|
||||
output = "helicopter:blades",
|
||||
output = "nss_helicopter:blades",
|
||||
recipe = {
|
||||
{"", "default:steel_ingot", ""},
|
||||
{"default:steel_ingot", "default:diamond", "default:steel_ingot"},
|
||||
|
@ -66,7 +66,7 @@ if minetest.get_modpath("default") then
|
|||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "helicopter:cabin",
|
||||
output = "nss_helicopter:cabin",
|
||||
recipe = {
|
||||
{"default:copperblock", "default:diamondblock", ""},
|
||||
{"default:steelblock", "default:mese_block", "default:glass"},
|
||||
|
@ -74,10 +74,10 @@ if minetest.get_modpath("default") then
|
|||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "helicopter:heli",
|
||||
output = "nss_helicopter:heli",
|
||||
recipe = {
|
||||
{"", "helicopter:blades"},
|
||||
{"helicopter:blades", "helicopter:cabin"},
|
||||
{"", "nss_helicopter:blades"},
|
||||
{"nss_helicopter:blades", "nss_helicopter:cabin"},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@ local color_def = {
|
|||
["#ff0098"] = "Magenta",
|
||||
}
|
||||
|
||||
minetest.register_entity('helicopter:seat_base',{
|
||||
minetest.register_entity("nss_helicopter:seat_base",{
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
collide_with_objects=false,
|
||||
|
@ -42,7 +42,7 @@ initial_properties = {
|
|||
|
||||
})
|
||||
|
||||
minetest.register_entity("helicopter:heli", {
|
||||
minetest.register_entity("nss_helicopter:heli", {
|
||||
initial_properties = {
|
||||
physical = true,
|
||||
collide_with_objects = true,
|
||||
|
@ -58,6 +58,8 @@ minetest.register_entity("helicopter:heli", {
|
|||
},
|
||||
|
||||
driver_name = nil,
|
||||
shaded = true,
|
||||
show_on_minimap = true,
|
||||
sound_handle = nil,
|
||||
tilting = vector.new(),
|
||||
energy = 0.001,
|
||||
|
@ -68,7 +70,7 @@ minetest.register_entity("helicopter:heli", {
|
|||
hp_max = 50,
|
||||
color = "#0063b0",
|
||||
_passenger = nil,
|
||||
_by_mouse = helicopter.turn_player_look,
|
||||
_by_mouse = true, --helicopter.turn_player_look,
|
||||
|
||||
get_staticdata = function(self) -- unloaded/unloads ... is now saved
|
||||
return minetest.serialize({
|
||||
|
@ -96,16 +98,16 @@ minetest.register_entity("helicopter:heli", {
|
|||
|
||||
helicopter.paint(self, self.color)
|
||||
local pos = self.object:get_pos()
|
||||
local pointer=minetest.add_entity(pos,'helicopter:pointer')
|
||||
local pointer=minetest.add_entity(pos,'nss_helicopter:pointer')
|
||||
local energy_indicator_angle = ((self.energy * 18) - 90) * -1
|
||||
pointer:set_attach(self.object,'',{x=0,y=11.26,z=9.37},{x=0,y=0,z=energy_indicator_angle})
|
||||
self.pointer = pointer
|
||||
|
||||
local pilot_seat_base=minetest.add_entity(pos,'helicopter:seat_base')
|
||||
local pilot_seat_base=minetest.add_entity(pos,'nss_helicopter:seat_base')
|
||||
pilot_seat_base:set_attach(self.object,'',{x=4.2,y=10,z=2},{x=0,y=0,z=0})
|
||||
self.pilot_seat_base = pilot_seat_base
|
||||
|
||||
local passenger_seat_base=minetest.add_entity(pos,'helicopter:seat_base')
|
||||
local passenger_seat_base=minetest.add_entity(pos,'nss_helicopter:seat_base')
|
||||
passenger_seat_base:set_attach(self.object,'',{x=-4.2,y=10,z=2},{x=0,y=0,z=0})
|
||||
self.passenger_seat_base = passenger_seat_base
|
||||
|
||||
|
@ -293,7 +295,7 @@ minetest.register_entity("helicopter:heli", {
|
|||
if self.hp_max <= 0 then
|
||||
if helicopter.punch_inv then
|
||||
local pinv = puncher:get_inventory()
|
||||
local stack = ItemStack("helicopter:heli")
|
||||
local stack = ItemStack("nss_helicopter:heli")
|
||||
local imeta = stack:get_meta()
|
||||
|
||||
-- store fuel level & color
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
--
|
||||
helicopter.fuel = {['biofuel:biofuel'] = 1,['biofuel:bottle_fuel'] = 1,['biofuel:phial_fuel'] = 0.25, ['biofuel:fuel_can'] = 10}
|
||||
|
||||
minetest.register_entity('helicopter:pointer',{
|
||||
minetest.register_entity("nss_helicopter:pointer",{
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
collide_with_objects=false,
|
||||
|
|
|
@ -35,6 +35,25 @@ function helicopter.setText(self)
|
|||
end
|
||||
end
|
||||
|
||||
--returns 0 for old, 1 for new
|
||||
function helicopter.detect_player_api(player)
|
||||
local player_proterties = player:get_properties()
|
||||
local mesh = "character.b3d"
|
||||
if player_proterties.mesh == mesh then
|
||||
local models = player_api.registered_models
|
||||
local character = models[mesh]
|
||||
if character then
|
||||
if character.animations.sit.eye_height then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
-- attach player
|
||||
function helicopter.attach(self, player)
|
||||
local name = player:get_player_name()
|
||||
|
@ -45,15 +64,22 @@ function helicopter.attach(self, player)
|
|||
{object = self.object, gain = 2.0, max_hear_distance = 32, loop = true,})
|
||||
self.object:set_animation_frame_speed(60)
|
||||
|
||||
|
||||
-- attach the driver
|
||||
player:set_attach(self.pilot_seat_base, "", {x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||
player:set_eye_offset({x = 0, y = -4, z = 1}, {x = 0, y = 8, z = -30})
|
||||
if helicopter.detect_player_api(player) == 0 then
|
||||
player:set_eye_offset({x = 0, y = -4, z = 1}, {x = 0, y = 8, z = -30})
|
||||
else
|
||||
player:set_eye_offset({x = 0, y = 2, z = 1}, {x = 0, y = 8, z = -30})
|
||||
end
|
||||
player_api.player_attached[name] = true
|
||||
player_api.set_animation(player, "sit")
|
||||
-- make the driver sit
|
||||
minetest.after(0.2, function()
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player then
|
||||
player_api.set_animation(player, "sit")
|
||||
--player_api.set_animation(player, "sit")
|
||||
player:set_animation({x = 81, y = 160},30, 0, true)
|
||||
update_heli_hud(player)
|
||||
end
|
||||
end)
|
||||
|
@ -94,13 +120,18 @@ function helicopter.attach_pax(self, player)
|
|||
self._passenger = name
|
||||
-- attach the passenger
|
||||
player:set_attach(self.passenger_seat_base, "", {x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||
player:set_eye_offset({x = 0, y = -4, z = 1}, {x = 0, y = 8, z = -5})
|
||||
if helicopter.detect_player_api(player) == 0 then
|
||||
player:set_eye_offset({x = 0, y = -4, z = 1}, {x = 0, y = 8, z = -5})
|
||||
else
|
||||
player:set_eye_offset({x = 0, y = 2, z = 1}, {x = 0, y = 8, z = -5})
|
||||
end
|
||||
player_api.player_attached[name] = true
|
||||
player_api.set_animation(player, "sit")
|
||||
-- make the driver sit
|
||||
minetest.after(0.2, function()
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player then
|
||||
player_api.set_animation(player, "sit")
|
||||
player:set_animation({x = 81, y = 160},30, 0, true)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
@ -113,10 +144,12 @@ function helicopter.dettach_pax(self, player)
|
|||
self._passenger = nil
|
||||
|
||||
-- detach the player
|
||||
player:set_detach()
|
||||
player_api.player_attached[name] = nil
|
||||
player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||
player_api.set_animation(player, "stand")
|
||||
if player then
|
||||
player:set_detach()
|
||||
player_api.player_attached[name] = nil
|
||||
player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||
player_api.set_animation(player, "stand")
|
||||
end
|
||||
end
|
||||
|
||||
-- destroy the helicopter
|
||||
|
@ -158,5 +191,5 @@ function helicopter.destroy(self, puncher)
|
|||
|
||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'default:steelblock')
|
||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'default:copperblock')
|
||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'helicopter:blades')
|
||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'nss_helicopter:blades')
|
||||
end
|
||||
|
|
16
init.lua
16
init.lua
|
@ -29,14 +29,14 @@ helicopter.colors ={
|
|||
yellow='#ffe400',
|
||||
}
|
||||
|
||||
dofile(minetest.get_modpath("helicopter") .. DIR_DELIM .. "settings.lua")
|
||||
dofile(minetest.get_modpath("nss_helicopter") .. DIR_DELIM .. "settings.lua")
|
||||
--dofile(minetest.get_modpath(minetest.get_current_modname()) .. DIR_DELIM .. "heli_hud.lua")
|
||||
dofile(minetest.get_modpath("helicopter") .. DIR_DELIM .. "heli_hud.lua")
|
||||
dofile(minetest.get_modpath("helicopter") .. DIR_DELIM .. "heli_utilities.lua")
|
||||
dofile(minetest.get_modpath("helicopter") .. DIR_DELIM .. "heli_entities.lua")
|
||||
dofile(minetest.get_modpath("helicopter") .. DIR_DELIM .. "heli_crafts.lua")
|
||||
dofile(minetest.get_modpath("helicopter") .. DIR_DELIM .. "heli_control.lua")
|
||||
dofile(minetest.get_modpath("helicopter") .. DIR_DELIM .. "heli_fuel_management.lua")
|
||||
dofile(minetest.get_modpath("nss_helicopter") .. DIR_DELIM .. "heli_hud.lua")
|
||||
dofile(minetest.get_modpath("nss_helicopter") .. DIR_DELIM .. "heli_utilities.lua")
|
||||
dofile(minetest.get_modpath("nss_helicopter") .. DIR_DELIM .. "heli_entities.lua")
|
||||
dofile(minetest.get_modpath("nss_helicopter") .. DIR_DELIM .. "heli_crafts.lua")
|
||||
dofile(minetest.get_modpath("nss_helicopter") .. DIR_DELIM .. "heli_control.lua")
|
||||
dofile(minetest.get_modpath("nss_helicopter") .. DIR_DELIM .. "heli_fuel_management.lua")
|
||||
|
||||
|
||||
helicopter.helicopter_last_time_command = 0
|
||||
|
@ -46,7 +46,7 @@ helicopter.helicopter_last_time_command = 0
|
|||
--
|
||||
|
||||
if not minetest.global_exists("matrix3") then
|
||||
dofile(minetest.get_modpath("helicopter") .. DIR_DELIM .. "matrix.lua")
|
||||
dofile(minetest.get_modpath("nss_helicopter") .. DIR_DELIM .. "matrix.lua")
|
||||
end
|
||||
|
||||
helicopter.creative = minetest.global_exists("creative")
|
||||
|
|
2
mod.conf
2
mod.conf
|
@ -1,4 +1,4 @@
|
|||
name = helicopter
|
||||
name = nss_helicopter
|
||||
depends = player_api, biofuel
|
||||
optional_depends = default, creative
|
||||
description = It adds an expensive helicopter with power consumption. It uses biofuel to fly. With biofuel barrels on your inventory, you can recharge your helicopter attaching himself into it (with right click on seat) and punching the seat after. It does not refuel on flying, only when landed. The power consumption increases as high you climb, so, stay below the flight level 100.
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
mount_punch_inv (Place in inventory) bool false
|
||||
|
||||
# Use facing direction to turn instead of a/d keys by default.
|
||||
mount_turn_player_look (Turn with look direction) bool false
|
||||
mount_turn_player_look (Turn with look direction) bool true
|
||||
|
|
Loading…
Reference in New Issue