first commit
25
.luacheckrc
Executable file
@ -0,0 +1,25 @@
|
||||
unused_args = false
|
||||
allow_defined_top = true
|
||||
|
||||
globals = {
|
||||
"minetest",
|
||||
"mobkit",
|
||||
"core",
|
||||
"player_api",
|
||||
"player_monoids",
|
||||
"math.sign",
|
||||
}
|
||||
|
||||
read_globals = {
|
||||
string = {fields = {"split"}},
|
||||
table = {fields = {"copy", "getn"}},
|
||||
|
||||
-- Builtin
|
||||
"vector", "ItemStack",
|
||||
"dump", "DIR_DELIM", "VoxelArea", "Settings",
|
||||
|
||||
-- MTG
|
||||
"default", "sfinv", "creative",
|
||||
}
|
||||
|
||||
ignore = {"611"}
|
25
README.md
Normal file → Executable file
@ -1,2 +1,23 @@
|
||||
# b47_heli
|
||||
Another helicopter for minetest
|
||||
Minetest 5.4 mod: Heli
|
||||
========================================
|
||||
|
||||
B47 Helicopter
|
||||
|
||||
This is an implementarion for minetest of a simple helicopter using airutils new module
|
||||
Needs biofuel mod to refuel and fly
|
||||
|
||||
Shortcuts:
|
||||
|
||||
right click to enter and access menu
|
||||
punch with dye to paint (left or right, it have 2 colors)
|
||||
forward and backward: controls the movement to front and back
|
||||
left and right: controls the direction
|
||||
jump and sneak: controls the collective -> up and down movement
|
||||
|
||||
-----------------------
|
||||
License of source code:
|
||||
MIT (see file LICENSE)
|
||||
|
||||
License of media (textures and sounds):
|
||||
CC0
|
||||
|
||||
|
77
crafts.lua
Executable file
@ -0,0 +1,77 @@
|
||||
|
||||
if not minetest.settings:get_bool('ap_heli.disable_craftitems') then
|
||||
-- wing
|
||||
minetest.register_craftitem("heli:rotor",{
|
||||
description = "B47 Helicopter rotor",
|
||||
inventory_image = "heli_b47_rotor_ico.png",
|
||||
})
|
||||
-- fuselage
|
||||
minetest.register_craftitem("heli:fuselage",{
|
||||
description = "B47 Helicopter fuselage",
|
||||
inventory_image = "heli_b47_fuselage_ico.png",
|
||||
})
|
||||
end
|
||||
|
||||
-- pa28
|
||||
minetest.register_craftitem("heli:heli", {
|
||||
description = "B47 Helicopter",
|
||||
inventory_image = "heli_b47_ico_inv.png",
|
||||
liquids_pointable = false,
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
|
||||
local pointed_pos = pointed_thing.under
|
||||
--local node_below = minetest.get_node(pointed_pos).name
|
||||
--local nodedef = minetest.registered_nodes[node_below]
|
||||
|
||||
pointed_pos.y=pointed_pos.y+0.5
|
||||
local heli_ent = minetest.add_entity(pointed_pos, "heli:heli")
|
||||
if heli_ent and placer then
|
||||
local ent = heli_ent:get_luaentity()
|
||||
if ent then
|
||||
local owner = placer:get_player_name()
|
||||
ent.owner = owner
|
||||
heli_ent:set_yaw(placer:get_look_horizontal())
|
||||
itemstack:take_item()
|
||||
airutils.create_inventory(ent, ent._trunk_slots, owner)
|
||||
end
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
--
|
||||
-- crafting
|
||||
--
|
||||
|
||||
if not minetest.settings:get_bool('ap_heli.disable_craftitems') and minetest.get_modpath("default") then
|
||||
minetest.register_craft({
|
||||
output = "heli:rotor",
|
||||
recipe = {
|
||||
{"default:tin_ingot", "", "default:tin_ingot"},
|
||||
{"default:steel_ingot", "default:tinblock", "default:steel_ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "heli:fuselage",
|
||||
recipe = {
|
||||
{"default:glass", "default:diamondblock", "default:tin_ingot"},
|
||||
{"default:glass", "default:steel_ingot", "default:steel_ingot"},
|
||||
{"default:tin_ingot", "default:mese_block", "default:tin_ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "heli:heli",
|
||||
recipe = {
|
||||
{"heli:rotor",},
|
||||
{"heli:fuselage",},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
11
entities.lua
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
--
|
||||
-- entity
|
||||
--
|
||||
|
||||
ap_heli.vector_up = vector.new(0, 1, 0)
|
||||
|
||||
minetest.register_entity('heli:heli',
|
||||
airutils.properties_copy(ap_heli.plane_properties)
|
||||
)
|
||||
|
224
init.lua
Executable file
@ -0,0 +1,224 @@
|
||||
ap_heli={}
|
||||
|
||||
function ap_heli.register_parts_method(self)
|
||||
local pos = self.object:get_pos()
|
||||
|
||||
--[[local lights=minetest.add_entity(pos,'heli:p_lights')
|
||||
lights:set_attach(self.object,'',{x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||
self.lights = lights
|
||||
|
||||
local light=minetest.add_entity(pos,'heli:light')
|
||||
light:set_attach(self.object,'',{x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||
self.light = light]]--
|
||||
|
||||
--minetest.chat_send_all(self.initial_properties.textures[19])
|
||||
--airutils.paint(self.wheels:get_luaentity(), self._color)
|
||||
end
|
||||
|
||||
function ap_heli.destroy_parts_method(self)
|
||||
if self.wheels then self.wheels:remove() end
|
||||
if self.light then self.light:remove() end
|
||||
if self.lights then self.lights:remove() end
|
||||
|
||||
local pos = self.object:get_pos()
|
||||
if not minetest.settings:get_bool('ap_heli.disable_craftitems') then
|
||||
pos.y=pos.y+2
|
||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'heli:rotor')
|
||||
|
||||
for i=1,2 do
|
||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'default:tin_ingot')
|
||||
end
|
||||
|
||||
for i=1,6 do
|
||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'default:mese_crystal')
|
||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'default:diamond')
|
||||
end
|
||||
else
|
||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'heli:heli')
|
||||
end
|
||||
end
|
||||
|
||||
function ap_heli.step_additional_function(self)
|
||||
--position lights
|
||||
--[[
|
||||
if self._land_light == true then
|
||||
self.light:set_properties({textures={"pa28_landing_light.png"},glow=15})
|
||||
else
|
||||
self.light:set_properties({textures={"pa28_metal.png"},glow=0})
|
||||
end]]--
|
||||
|
||||
if (self.driver_name==nil) and (self.co_pilot==nil) then --pilot or copilot
|
||||
return
|
||||
end
|
||||
|
||||
local pos = self._curr_pos
|
||||
|
||||
local climb_angle = airutils.get_gauge_angle(self._climb_rate)
|
||||
self.object:set_bone_position("climber", {x=2.401,y=12.8818,z=19.60}, {x=0,y=0,z=climb_angle-90})
|
||||
|
||||
local energy_indicator_angle = airutils.get_gauge_angle((self._max_fuel - self._energy)/1) - 90
|
||||
self.object:set_bone_position("fuel_i", {x=0.671428, y=11.4485, z=19.60}, {x=0,y=0,z=-energy_indicator_angle+180})
|
||||
|
||||
--altimeter
|
||||
local altitude = (pos.y / 0.32) / 100
|
||||
local hour, minutes = math.modf( altitude )
|
||||
hour = math.fmod (hour, 10)
|
||||
minutes = minutes * 100
|
||||
minutes = (minutes * 100) / 100
|
||||
local minute_angle = (minutes*-360)/100
|
||||
local hour_angle = (hour*-360)/10 + ((minute_angle*36)/360)
|
||||
self.object:set_bone_position("altimeter_pt_1", {x=-1.35246, y=12.8837 , z=19.60}, {x=0, y=0, z=(hour_angle)})
|
||||
self.object:set_bone_position("altimeter_pt_2", {x=-1.35246, y=12.8837 , z=19.60}, {x=0, y=0, z=(minute_angle)})
|
||||
|
||||
--set stick position
|
||||
--[[local stick_z = 9 + (self._elevator_angle / self._elevator_limit )
|
||||
self.object:set_bone_position("stick.l", {x=-4.25, y=0.5, z=stick_z}, {x=0,y=0,z=self._rudder_angle})
|
||||
self.object:set_bone_position("stick.r", {x=4.25, y=0.5, z=stick_z}, {x=0,y=0,z=self._rudder_angle})]]--
|
||||
end
|
||||
|
||||
ap_heli.plane_properties = {
|
||||
initial_properties = {
|
||||
physical = true,
|
||||
collide_with_objects = true,
|
||||
collisionbox = {-1.2, 0, -1.2, 1.2, 2, 1.2},
|
||||
selectionbox = {-2, 0, -2, 2, 2, 2},
|
||||
visual = "mesh",
|
||||
backface_culling = false,
|
||||
mesh = "b47_heli.b3d",
|
||||
stepheight = 0.5,
|
||||
textures = {
|
||||
"airutils_painting.png", --cabine
|
||||
"airutils_metal.png", --motor
|
||||
"airutils_black2.png", --redução motor
|
||||
"airutils_painting.png", --tanques
|
||||
"airutils_painting_2.png", --estrutura empenagem
|
||||
"heli_b47_glass.png", --parabrisa
|
||||
"airutils_painting.png", --estabilizador horizontal
|
||||
"airutils_black.png", --interior
|
||||
"airutils_painting.png", --nacele rotor traseiro
|
||||
"airutils_black2.png", --eixo rotor traseiro
|
||||
"heli_b47_tail_rotor.png", --pas rotor traseiro
|
||||
"airutils_painting_2.png", --pintura eixo rotor principal
|
||||
"heli_b47_rotor.png", --rotor principal
|
||||
"airutils_white.png", --ponteiros
|
||||
"airutils_black.png", --assentos
|
||||
"heli_b47_panel.png", --painel de instrumentos
|
||||
"airutils_painting_2.png", --pintura ski
|
||||
"airutils_black2.png", --tampas cabeçotes
|
||||
"airutils_painting.png", --estabilizador vertical
|
||||
},
|
||||
},
|
||||
textures = {},
|
||||
_anim_frames = 12,
|
||||
driver_name = nil,
|
||||
sound_handle = nil,
|
||||
owner = "",
|
||||
static_save = true,
|
||||
infotext = "",
|
||||
hp_max = 50,
|
||||
shaded = true,
|
||||
show_on_minimap = true,
|
||||
springiness = 0.1,
|
||||
buoyancy = 1.02,
|
||||
physics = airutils.physics, --airutils.physics_floating,
|
||||
_vehicle_name = "B47 Helicopter",
|
||||
_seats = {{x=-4.2,y=9.5,z=10.52},{x=4.2,y=9.5,z=10.52},},
|
||||
_seats_rot = {0, 0, 0, 0}, --necessary when using reversed seats
|
||||
_have_copilot = true, --wil use the second position of the _seats list
|
||||
_have_landing_lights = false,
|
||||
_have_auto_pilot = false,
|
||||
_have_adf = false,
|
||||
_max_plane_hp = 50,
|
||||
_enable_fire_explosion = true,
|
||||
_longit_drag_factor = 0.01*0.01,
|
||||
_later_drag_factor = 0.01*0.01,
|
||||
_wing_angle_of_attack = 1.2,
|
||||
_wing_span = 10, --meters
|
||||
_min_speed = 0,
|
||||
_max_speed = 10,
|
||||
_max_fuel = 10,
|
||||
_speed_not_exceed = 16,
|
||||
_damage_by_wind_speed = 2,
|
||||
_hard_damage = true,
|
||||
_min_attack_angle = 0.2,
|
||||
_max_attack_angle = 90,
|
||||
_tail_lift_min_speed = 0,
|
||||
_tail_lift_max_speed = 0,
|
||||
_max_engine_acc = 20.0,
|
||||
_tail_angle = 0,
|
||||
_lift = 11,
|
||||
_trunk_slots = 8, --the trunk slots
|
||||
_rudder_limit = 40.0,
|
||||
_elevator_limit = 15.0,
|
||||
_elevator_response_attenuation = 4,
|
||||
_pitch_intensity = 0.4,
|
||||
_yaw_intensity = 20,
|
||||
_yaw_turn_rate = 14, --degrees
|
||||
_elevator_pos = {x=0, y=2.5, z=-45},
|
||||
_rudder_pos = {x=0,y=0,z=0},
|
||||
_aileron_r_pos = {x=0,y=0,z=0},
|
||||
_aileron_l_pos = {x=0,y=0,z=0},
|
||||
_color = "#0063b0",
|
||||
_color_2 = "#9f9f9f",
|
||||
_rudder_angle = 0,
|
||||
_acceleration = 0,
|
||||
_engine_running = false,
|
||||
_angle_of_attack = 0,
|
||||
_elevator_angle = 0,
|
||||
_power_lever = 0,
|
||||
_last_applied_power = 0,
|
||||
_energy = 1.0,
|
||||
_last_vel = {x=0,y=0,z=0},
|
||||
_longit_speed = 0,
|
||||
_show_hud = false,
|
||||
_instruction_mode = false, --flag to intruction mode
|
||||
_command_is_given = false, --flag to mark the "owner" of the commands now
|
||||
_last_accell = {x=0,y=0,z=0},
|
||||
_last_time_command = 1,
|
||||
_inv = nil,
|
||||
_inv_id = "",
|
||||
_collision_sound = "airutils_collision", --the col sound
|
||||
_engine_sound = "airutils_heli_snd",
|
||||
_painting_texture = {"airutils_painting.png",}, --the texture to paint
|
||||
_painting_texture_2 = {"airutils_painting_2.png",}, --the texture to paint
|
||||
_mask_painting_associations = {},
|
||||
_register_parts_method = ap_heli.register_parts_method, --the method to register plane parts
|
||||
_destroy_parts_method = ap_heli.destroy_parts_method,
|
||||
_plane_y_offset_for_bullet = 1,
|
||||
_fuel_consumption_divisor = 200000,
|
||||
|
||||
_yaw_by_mouse = true,
|
||||
_climb_speed = 2,
|
||||
_ground_effect_ammount_percent = 0.01,
|
||||
_min_collective = 1.0,
|
||||
_stable_collective = 1.402,
|
||||
_rotor_speed = 15,
|
||||
_rotor_idle_speed = 14.5,
|
||||
_tilt_angle = 8,
|
||||
--_custom_punch_when_attached = ww1_planes_lib._custom_punch_when_attached, --the method to execute click action inside the plane
|
||||
_custom_pilot_formspec = airutils.pilot_formspec,
|
||||
_custom_step_additional_function = ap_heli.step_additional_function,
|
||||
|
||||
get_staticdata = airutils.get_staticdata,
|
||||
on_deactivate = airutils.on_deactivate,
|
||||
on_activate = airutils.on_activate,
|
||||
logic = airutils.logic_heli,
|
||||
on_step = airutils.on_step,
|
||||
on_punch = airutils.on_punch,
|
||||
on_rightclick = airutils.on_rightclick,
|
||||
}
|
||||
|
||||
dofile(minetest.get_modpath("heli") .. DIR_DELIM .. "crafts.lua")
|
||||
dofile(minetest.get_modpath("heli") .. DIR_DELIM .. "entities.lua")
|
||||
|
||||
--
|
||||
-- items
|
||||
--
|
||||
|
||||
settings = Settings(minetest.get_worldpath() .. "/ap_heli.conf")
|
||||
local function fetch_setting(name)
|
||||
local sname = name
|
||||
return settings and settings:get(sname) or minetest.settings:get(sname)
|
||||
end
|
||||
|
||||
|
6
mod.conf
Executable file
@ -0,0 +1,6 @@
|
||||
name = heli
|
||||
depends = airutils
|
||||
optional_depends = climate_api,biofuel
|
||||
author = APercy
|
||||
description = Adds a craftable B47 Helicopter
|
||||
title = B47 Helicopter
|
BIN
models/b47_heli.b3d
Executable file
BIN
textures/heli_b47_fuselage_ico.png
Executable file
After Width: | Height: | Size: 16 KiB |
BIN
textures/heli_b47_glass.png
Executable file
After Width: | Height: | Size: 8.6 KiB |
BIN
textures/heli_b47_ico_inv.png
Executable file
After Width: | Height: | Size: 21 KiB |
BIN
textures/heli_b47_panel.png
Executable file
After Width: | Height: | Size: 18 KiB |
BIN
textures/heli_b47_rotor.png
Executable file
After Width: | Height: | Size: 5.7 KiB |
BIN
textures/heli_b47_rotor_ico.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
textures/heli_b47_tail_rotor.png
Executable file
After Width: | Height: | Size: 5.3 KiB |