Noch mehr mods

This commit is contained in:
N-Nachtigal 2025-05-18 04:02:23 +02:00
parent a063db5d3b
commit cf017b2ca1
527 changed files with 21113 additions and 181 deletions

View file

@ -0,0 +1,23 @@
unused_args = false
allow_defined_top = true
globals = {
"minetest",
"airutils",
"core",
"player_api",
"math.sign",
}
read_globals = {
string = {fields = {"split"}},
table = {fields = {"copy", "getn"}},
-- Builtin
"vector", "ItemStack",
"dump", "DIR_DELIM", "VoxelArea", "Settings",
-- MTG
"default", "sfinv", "creative",
}

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 APercy - Alexsandro Percy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,113 @@
Minetest 5.4 mod: Steampunk Blimp
========================================
This mod implements a fantasy steampunk blimp for minetest.
The mod was made for fun, but tries to provide an immersion on it's operation.
It can carry 7 people.
To fly it, it is necessary to provide some items, such as fuel to be burned and
water for the boiler. The fuel can be coal, coal block and wood. To supply it,
be on board and punch the necessary items on the airship. There is another way to
load water to the boiler: if it is landed on water, it can load it through the
menu. But the current pressure will be lost.
Activate the furnace in the first option of the menu. Take control by activating
the option "Take the Control".
The information panel will be on the left and bottom of the screen. Wait for the
boiler to reach the proper pressure for operation (green) before operating the power lever.
To go up, press Jump (space). Note that it takes some pressure from the boiler. To go down,
hold sneak (shift).
Forward increases the propeller power, Backward reduces.
There is a power mode. When the lever reaches the up limit, hold E
and forward to increase the acceleration. But note that the boiler will lose pressure.
The blimp inventory can be accessed by Aux (E) + rightclick.
Shared owners:
This vehicle was made to be shared with a team. So the owner can set more users to
operate it. Inside the blimp, just use the command /blimp_share <name>
- To go reverse, hold aux (E key) and backward together.
- To remove someone from the sharing, /blimp_remove <name>
- To list the owners, /blimp_list
- To lock the blimp access, so only the owners can enter: /blimp_lock true
- To let anyone enter, /blimp_lock false
All shared owners can access the blimp inventory
Painting:
As the planes, punch a dye against the hull, so the primary color will change
- To change the secondary color, punch a dye, but holding Aux (E) key.
It is possible to set a logo on your blimp, so enter inside it and type the command /blimp_logo
Only the original owner can do the paintings
Shortcuts:
punch with dye to paint
forward and backward while in drive position: controls the power lever
left and right while in drive position: controls the direction
jump and sneak: controls the up and down movement
- right click to enter and access menu
- E + right click while inside: acess inventory
- E + backward while in drive position: the machine does backward
- E + foward while in drive position: extra power
Tip:
Drive it gently.
The captain can leave the drive position to walk too
If a player goes timeout or logoff in flight, the blimp will "rescue" him if no other player
enter the blimp, so is a good idea wait the friend at a secure place far from anyone who
wants to enter the blimp.
Know issues:
The walk movement inside the ship is affected by server lag, because the lack of
an interpolation method on attach function.
Rubber-band bug is from minetest nature, just close and reopen minetest to solve.
Or try to live the Michael Jackson's way of life and learn the Moonwalk properly XD
Some old versions of minetest can have an strange issue, the camera is set to
the map center. So if it happens, just type /blimp_eject to be free again.
License of source code:
MIT (see file LICENSE)
License of media (textures and sounds):
---------------------------------------
collision.ogg by APercy, CC0
Blimp model and textures by APercy. CC BY-SA 3.0
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
Copyright (C) 2022 Alexsandro Percy (APercy) <alexsandro.percy@gmail.com>
You are free to:
Share — copy and redistribute the material in any medium or format.
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
The licensor cannot revoke these freedoms as long as you follow the license terms.
Under the following terms:
Attribution — You must give appropriate credit, provide a link to the license, and
indicate if changes were made. You may do so in any reasonable manner, but not in any way
that suggests the licensor endorses you or your use.
ShareAlike — If you remix, transform, or build upon the material, you must distribute
your contributions under the same license as the original.
No additional restrictions — You may not apply legal terms or technological measures that
legally restrict others from doing anything the license permits.
Notices:
You do not have to comply with the license for elements of the material in the public
domain or where your use is permitted by an applicable exception or limitation.
No warranties are given. The license may not give you all of the permissions necessary
for your intended use. For example, other rights such as publicity, privacy, or moral
rights may limit how you use the material.
For more details:
http://creativecommons.org/licenses/by-sa/3.0/

View file

@ -0,0 +1,158 @@
--global constants
steampunk_blimp.vector_up = vector.new(0, 1, 0)
function steampunk_blimp.check_node_below(obj)
local pos_below = obj:get_pos()
pos_below.y = pos_below.y - 0.1
local node_below = minetest.get_node(pos_below).name
local nodedef = minetest.registered_nodes[node_below]
local touching_ground = not nodedef or -- unknown nodes are solid
nodedef.walkable or false
local liquid_below = not touching_ground and nodedef.liquidtype ~= "none"
return touching_ground, liquid_below
end
function steampunk_blimp.powerAdjust(self,dtime,factor,dir,max_power)
local max = max_power or 100
local add_factor = factor/2
add_factor = add_factor * (dtime/steampunk_blimp.ideal_step) --adjusting the command speed by dtime
if dir == 1 then
if self._power_lever < max then
self._power_lever = self._power_lever + add_factor
end
if self._power_lever > max then
self._power_lever = max
end
end
if dir == -1 then
self._power_lever = self._power_lever - add_factor
if self._power_lever < -15 then self._power_lever = -15 end
end
end
function steampunk_blimp.control(self, dtime, hull_direction, longit_speed, accel)
if self._last_time_command == nil then self._last_time_command = 0 end
self._last_time_command = self._last_time_command + dtime
if self._last_time_command > 1 then self._last_time_command = 1 end
local player = nil
if self.driver_name then
player = minetest.get_player_by_name(self.driver_name)
end
local retval_accel = accel;
-- player control
local ctrl = nil
if player and self._at_control == true then
ctrl = player:get_player_control()
if self.anchored == false then
local factor = 1
if ctrl.up then
local can_acc = true
if self._power_lever >= 82 then can_acc = false end
if ctrl.aux1 then can_acc = true end
if can_acc then
steampunk_blimp.powerAdjust(self, dtime, factor, 1)
end
elseif ctrl.down then
steampunk_blimp.powerAdjust(self, dtime, factor, -1)
end
else
--anchor away, so stop!
self._power_lever = 0
end
if not ctrl.aux1 and self._power_lever < 0 then self._power_lever = 0 end
self._is_going_up = false
if ctrl.jump then
if self._boiler_pressure > 0 then
self._baloon_buoyancy = 1.02
if self.isinliquid then self._baloon_buoyancy = 1.10 end
end
self._is_going_up = true
elseif ctrl.sneak then
self._baloon_buoyancy = -1.02
end
-- rudder
local rudder_limit = 30
local speed = 10
if ctrl.right then
self._rudder_angle = math.max(self._rudder_angle-speed*dtime,-rudder_limit)
elseif ctrl.left then
self._rudder_angle = math.min(self._rudder_angle+speed*dtime,rudder_limit)
end
end
--make the blimp loss height when without pressure (and not anchored)
if self.anchored == false and not self.isinliquid then
if self._boiler_pressure <= 0 then
self._baloon_buoyancy = -0.2
end
end
--engine acceleration calc
local engineacc = (self._power_lever * steampunk_blimp.max_engine_acc) / 100;
--do not exceed
local max_speed = 3
if longit_speed > max_speed then
engineacc = engineacc - (longit_speed-max_speed)
end
if engineacc ~= nil then
retval_accel=vector.add(accel,vector.multiply(hull_direction,engineacc))
end
--minetest.chat_send_all('paddle: '.. paddleacc)
if longit_speed > 0 then
if ctrl then
if not ctrl.right or not ctrl.left then
steampunk_blimp.rudder_auto_correction(self, longit_speed, dtime)
end
else
steampunk_blimp.rudder_auto_correction(self, longit_speed, dtime)
end
end
steampunk_blimp.buoyancy_auto_correction(self, self.dtime)
return retval_accel
end
function steampunk_blimp.rudder_auto_correction(self, longit_speed, dtime)
local factor = 1
if self._rudder_angle > 0 then factor = -1 end
local correction = (steampunk_blimp.rudder_limit*(longit_speed/2000)) * factor * (dtime/steampunk_blimp.ideal_step)
local before_correction = self._rudder_angle
local new_rudder_angle = self._rudder_angle + correction
if math.sign(before_correction) ~= math.sign(new_rudder_angle) then
self._rudder_angle = 0
else
self._rudder_angle = new_rudder_angle
end
end
function steampunk_blimp.buoyancy_auto_correction(self, dtime)
local factor = 1
--minetest.chat_send_player(self.driver_name, "antes: " .. self._baloon_buoyancy)
if self._baloon_buoyancy > 0 then factor = -1 end
local time_correction = (dtime/steampunk_blimp.ideal_step)
if time_correction < 1 then time_correction = 1 end
local intensity = 0.2
local correction = (intensity*factor) * time_correction
if math.abs(correction) > 0.5 then correction = 0.5 * math.sign(correction) end
--minetest.chat_send_player(self.driver_name, correction)
local before_correction = self._baloon_buoyancy
local new_baloon_buoyancy = self._baloon_buoyancy + correction
if math.sign(before_correction) ~= math.sign(new_baloon_buoyancy) then
self._baloon_buoyancy = 0
else
self._baloon_buoyancy = new_baloon_buoyancy
end
--minetest.chat_send_player(self.driver_name, "depois: " .. self._baloon_buoyancy)
end

View file

@ -0,0 +1,96 @@
local min = math.min
local abs = math.abs
function steampunk_blimp.physics(self)
local friction = 0.996
local vel=self.object:get_velocity()
-- dumb friction
if self.isonground and not self.isinliquid then
--minetest.chat_send_all("with friction")
vel = {x=vel.x*friction,
y=vel.y,
z=vel.z*friction}
self.object:set_velocity(vel)
end
-- bounciness
if self.springiness and self.springiness > 0 then
local vnew = vector.new(vel)
if not self.collided then -- ugly workaround for inconsistent collisions
for _,k in ipairs({'y','z','x'}) do
if vel[k]==0 and abs(self.lastvelocity[k])> 0.1 then
vnew[k]=-self.lastvelocity[k]*self.springiness
end
end
end
if not vector.equals(vel,vnew) then
self.collided = true
else
if self.collided then
vnew = vector.new(self.lastvelocity)
end
self.collided = false
end
--minetest.chat_send_all("vnew")
self.object:set_velocity(vnew)
end
--[[else
self.object:set_pos(self.object:get_pos())
if not self.isonground then
--minetest.chat_send_all("test")
self.object:set_velocity(vel)
end
end]]--
--buoyancy
local surface = nil
local spos = airutils.get_stand_pos(self)
spos.y = spos.y+0.01
-- get surface height
local snodepos = airutils.get_node_pos(spos)
local surfnode = airutils.nodeatpos(spos)
while surfnode and (surfnode.drawtype == 'liquid' or surfnode.drawtype == 'flowingliquid') do
surface = snodepos.y +0.5
if surface > spos.y+self.height then break end
snodepos.y = snodepos.y+1
surfnode = airutils.nodeatpos(snodepos)
end
local accell
self.water_drag = 0.1
self.object:move_to(self.object:get_pos())
local time_correction = (self.dtime/steampunk_blimp.ideal_step)
if time_correction < 1 then time_correction = 1 end
local y_accel = self._baloon_buoyancy*time_correction
local max_y_acell = 0.6
if y_accel > max_y_acell then y_accel = max_y_acell end
if y_accel < (-1*max_y_acell) then y_accel = -1*max_y_acell end
if surface then
self.isinliquid = true
local height = self.height
local submergence = min(surface-spos.y,height)/height
-- local balance = self.buoyancy*self.height
local buoyacc = airutils.gravity*(self.buoyancy-submergence)
--local buoyacc = self._baloon_buoyancy*(self.buoyancy-submergence)
accell = {x=-vel.x*self.water_drag,y=buoyacc-(vel.y*abs(vel.y)*0.4),z=-vel.z*self.water_drag}
--local v_accell = {x=0,y=buoyacc-(vel.y*abs(vel.y)*0.4),z=0}
airutils.set_acceleration(self.object,accell)
if self._baloon_buoyancy > 0 then
airutils.set_acceleration(self.object,{x=0,y=y_accel,z=0})
end
else
self.isinliquid = false
if self._baloon_buoyancy == 0 then
local velocity = vector.new(vel)
velocity.y = velocity.y - (velocity.y/100)
self.object:set_velocity(velocity)
end
--minetest.chat_send_all("_baloon_buoyancy: "..self._baloon_buoyancy.." - dtime: "..self.dtime.." - ideal: "..steampunk_blimp.ideal_step)
airutils.set_acceleration(self.object,{x=0,y=y_accel,z=0})
end
end

View file

@ -0,0 +1,95 @@
steampunk_blimp.PRESSURE_CONSUMPTION = 500
local adjust_variable = 500
local lost_power = (1/steampunk_blimp.FUEL_CONSUMPTION)*adjust_variable
local gained_pressure = (2/steampunk_blimp.FUEL_CONSUMPTION)*adjust_variable
local lost_water = (1/steampunk_blimp.WATER_CONSUMPTION)
steampunk_blimp.boiler_min = 155
steampunk_blimp.boiler_max = 310
function steampunk_blimp.start_boiler(self)
if self._boiler_pressure < 150 then
-- sound and animation
if self.sound_handle_pistons then
minetest.sound_stop(self.sound_handle_pistons)
self.sound_handle_pistons = nil
end
elseif self._boiler_pressure >= 150 then
-- sound
--minetest.chat_send_all(dump(self.sound_handle_pistons))
if self.sound_handle_pistons == nil then
if self.object then
self.sound_handle_pistons = minetest.sound_play({name = steampunk_blimp.piston_sound.name},--"default_item_smoke"},
{object = self.object, gain = steampunk_blimp.piston_sound.gain,
pitch = steampunk_blimp.piston_sound.pitch,
max_hear_distance = 32,
loop = true,})
end
end
end
end
local function boiler_step(self, accel)
steampunk_blimp.start_boiler(self)
local consumed_pressure = self._power_lever/steampunk_blimp.PRESSURE_CONSUMPTION
if self._engine_running == false then consumed_pressure = consumed_pressure + lost_power end
if self._boiler_pressure > steampunk_blimp.boiler_max then self._boiler_pressure = steampunk_blimp.boiler_max end
if self._boiler_pressure > steampunk_blimp.boiler_min then
--[[-- sound and animation
steampunk_blimp.engineSoundPlay(self)
self.object:set_animation_frame_speed(steampunk_blimp.iddle_rotation)]]--
steampunk_blimp.engine_set_sound_and_animation(self)
self._water_level = self._water_level - lost_water
end
if self._boiler_pressure < steampunk_blimp.boiler_min then
self._power_lever = 0
--if self.sound_handle_pistons then minetest.sound_stop(self.sound_handle_pistons) end
self.object:set_animation_frame_speed(0)
end
self._boiler_pressure = self._boiler_pressure - consumed_pressure
--lets lose more pressure if it's going up
if self._is_going_up == true then
--minetest.chat_send_all("subindo "..consumed_pressure)
self._boiler_pressure = self._boiler_pressure - (200/steampunk_blimp.PRESSURE_CONSUMPTION)
end
if self._boiler_pressure < 0 then self._boiler_pressure = 0 end
if self._water_level < 0 then self._water_level = 0 end
end
local function furnace_step(self, accel)
if self._energy > 0 and self._engine_running then
local consumed_power = (1/steampunk_blimp.FUEL_CONSUMPTION)
local time_correction = (self.dtime/steampunk_blimp.ideal_step)
if time_correction < 1 then time_correction = 1 end
local dtimed_pressure = gained_pressure*time_correction
self._boiler_pressure = self._boiler_pressure + dtimed_pressure --pressure for the boiler
self._energy = self._energy - consumed_power; --removes energy
end
if self._energy <= 0 or self._water_level <= 0 then
self._engine_running = false
if self.sound_handle then minetest.sound_stop(self.sound_handle) end
end
end
function steampunk_blimp.engine_step(self, accel)
furnace_step(self, accel)
boiler_step(self, accel)
if self.driver_name then
local player = minetest.get_player_by_name(self.driver_name)
local pressure = steampunk_blimp.get_pointer_angle(self._boiler_pressure, 200 )
local water = steampunk_blimp.get_pointer_angle(self._water_level, steampunk_blimp.MAX_WATER)
local coal = self._energy
--minetest.chat_send_all(self._power_lever)
steampunk_blimp.update_hud(player, coal, 180-water, -pressure, self._power_lever)
end
end

View file

@ -0,0 +1,612 @@
--
-- constants
--
local LONGIT_DRAG_FACTOR = 0.13*0.13
local LATER_DRAG_FACTOR = 2.0
--
-- entity
--
core.register_entity('steampunk_blimp:fire',{
initial_properties = {
physical = false,
collide_with_objects=false,
pointable=false,
glow = 0,
visual = "mesh",
mesh = "steampunk_blimp_light.b3d",
textures = {
"steampunk_blimp_alpha.png",
},
},
on_activate = function(self,std)
self.sdata = core.deserialize(std) or {}
if self.sdata.remove then self.object:remove() end
end,
get_staticdata=function(self)
self.sdata.remove=true
return core.serialize(self.sdata)
end,
})
--
-- seat pivot
--
core.register_entity('steampunk_blimp:stand_base',{
initial_properties = {
physical = false,
collide_with_objects=false,
collisionbox = {-2, -2, -2, 2, 0, 2},
pointable=false,
visual = "mesh",
mesh = "steampunk_blimp_stand_base.b3d",
textures = {"steampunk_blimp_alpha.png",},
},
dist_moved = 0,
on_activate = function(self,std)
self.sdata = core.deserialize(std) or {}
if self.sdata.remove then self.object:remove() end
end,
get_staticdata=function(self)
self.sdata.remove=true
return core.serialize(self.sdata)
end,
})
core.register_entity("steampunk_blimp:blimp", {
initial_properties = {
physical = true,
collide_with_objects = true, --true,
collisionbox = {-4, -2.5, -4, 4, 9, 4}, --{-1,0,-1, 1,0.3,1},
--selectionbox = {-0.6,0.6,-0.6, 0.6,1,0.6},
visual = "mesh",
backface_culling = false,
mesh = "steampunk_blimp.b3d",
textures = steampunk_blimp.textures_copy(),
},
textures = {},
driver_name = nil,
sound_handle = nil,
static_save = true,
infotext = "A nice blimp",
lastvelocity = vector.new(),
hp = 50,
color = "blue",
color2 = "white",
logo = "steampunk_blimp_alpha_logo.png",
timeout = 0;
buoyancy = 0.15,
max_hp = 50,
anchored = true,
physics = steampunk_blimp.physics,
hull_integrity = nil,
owner = "",
time_total = 0,
_shared_owners = {},
_engine_running = false,
_power_lever = 0,
_last_applied_power = 0,
_at_control = false,
_rudder_angle = 0,
_baloon_buoyancy = 0,
_show_hud = true,
_energy = 1.0,--0.001,
_water_level = 1.0,
_boiler_pressure = 1.0, --min 155 max 310
_is_going_up = false, --to tell the boiler to lose pressure
_passengers = {}, --passengers list
_passengers_base = {}, --obj id
_passengers_base_pos = steampunk_blimp.copy_vector({}),
_passenger_is_sit = {}, -- 0, 1, 2, 3 or 4 ==> stand, 0, 90, 180, 270 --the sit rotation
_passengers_locked = false,
_disconnection_check_time = 0,
_inv = nil,
_inv_id = "",
_ship_name = "",
_name_color = 0,
_name_hor_aligment = 3.0,
item = "steampunk_blimp:blimp",
_vehicle_name = "Steampunk Blimp",
get_staticdata = function(self) -- unloaded/unloads ... is now saved
return core.serialize({
stored_baloon_buoyancy = self._baloon_buoyancy,
stored_energy = self._energy,
stored_water_level = self._water_level,
stored_boiler_pressure = self._boiler_pressure,
stored_owner = self.owner,
stored_shared_owners = self._shared_owners,
stored_hp = self.hp,
stored_color = self.color,
stored_color2 = self.color2,
stored_logo = self.logo,
stored_anchor = self.anchored,
stored_hull_integrity = self.hull_integrity,
stored_item = self.item,
stored_inv_id = self._inv_id,
stored_passengers = self._passengers, --passengers list
stored_passengers_locked = self._passengers_locked,
stored_ship_name = self._ship_name,
stored_vehicle_name = self._vehicle_name,
remove = self._remove or false,
})
end,
on_deactivate = function(self)
if self._remove ~= true then
airutils.save_inventory(self)
end
if self.sound_handle then core.sound_stop(self.sound_handle) end
if self.sound_handle_pistons then core.sound_stop(self.sound_handle_pistons) end
end,
on_activate = function(self, staticdata, dtime_s)
--core.chat_send_all('passengers: '.. dump(self._passengers))
if staticdata ~= "" and staticdata ~= nil then
local data = core.deserialize(staticdata) or {}
self._baloon_buoyancy = data.stored_baloon_buoyancy or 0
self._energy = data.stored_energy or 0
self._water_level = data.stored_water_level or 0
self._boiler_pressure = data.stored_boiler_pressure or 0
self.owner = data.stored_owner or ""
self._shared_owners = data.stored_shared_owners or {}
self.hp = 50 --data.stored_hp or 50
self.color = data.stored_color or "blue"
self.color2 = data.stored_color2 or "white"
self.logo = data.stored_logo or "steampunk_blimp_alpha_logo.png"
self.anchored = data.stored_anchor or false
self.buoyancy = data.stored_buoyancy or 0.15
self.hull_integrity = data.stored_hull_integrity
self.item = data.stored_item
self._passengers = data.stored_passengers or steampunk_blimp.copy_vector({[1]=nil, [2]=nil, [3]=nil, [4]=nil, [5]=nil, [6]=nil, [7]=nil})
self._passengers_locked = data.stored_passengers_locked
self._ship_name = data.stored_ship_name
self._vehicle_name = data.stored_vehicle_name
self._remove = data.remove or false
if self._remove ~= true then
self._inv_id = data.stored_inv_id
end
--core.debug("loaded: ", self._energy)
local properties = self.object:get_properties()
properties.infotext = data.stored_owner .. " nice blimp"
self.object:set_properties(properties)
if self._remove == true then
airutils.destroy_inventory(self)
self.object:remove()
return
end
end
local colstr = steampunk_blimp.colors[self.color]
if not colstr then
colstr = "blue"
self.color = colstr
end
steampunk_blimp.paint(self, self.color)
steampunk_blimp.paint2(self, self.color2)
local pos = self.object:get_pos()
if airutils.debug_log then
core.log("action","activating: "..self._vehicle_name.." from "..self.owner.." at position "..math.floor(pos.x)..","..math.floor(pos.y)..","..math.floor(pos.z))
end
local fire=core.add_entity(pos,'steampunk_blimp:fire')
fire:set_attach(self.object,'',{x=0.0,y=0.0,z=0.0},{x=0,y=0,z=0})
self.fire = fire
--passengers positions
self._passenger_is_sit = steampunk_blimp.copy_vector({})
self._passengers_base = steampunk_blimp.copy_vector({})
self._passengers_base_pos = steampunk_blimp.copy_vector({})
for i = 1,steampunk_blimp.max_seats,1
do
self._passenger_is_sit[i] = 0
self._passengers_base_pos[i] = steampunk_blimp.copy_vector(steampunk_blimp.passenger_pos[i])
self._passengers_base[i]=core.add_entity(pos,'steampunk_blimp:stand_base')
self._passengers_base[i]:set_attach(self.object,'',self._passengers_base_pos[i],{x=0,y=0,z=0})
end
--animation load - stoped
self.object:set_animation({x = 1, y = 47}, 0, 0, true)
self.object:set_bone_position("low_rudder_a", {x=0,y=0,z=-40}, {x=-5.35,y=0,z=0})
self.object:set_armor_groups({immortal=1})
airutils.actfunc(self, staticdata, dtime_s)
self.object:set_armor_groups({immortal=1})
if self._remove ~= true then
local inv = core.get_inventory({type = "detached", name = self._inv_id})
-- if the game was closed the inventories have to be made anew, instead of just reattached
if not inv then
airutils.create_inventory(self, steampunk_blimp.trunk_slots)
else
self.inv = inv
end
end
steampunk_blimp.engine_step(self, 0)
end,
on_step = function(self,dtime,colinfo)
self.dtime = math.min(dtime,0.2)
self.colinfo = colinfo
self.height = airutils.get_box_height(self)
-- physics comes first
local vel = self.object:get_velocity()
if colinfo then
self.isonground = colinfo.touching_ground
else
if self.lastvelocity.y==0 and vel.y==0 then
self.isonground = true
else
self.isonground = false
end
end
self:physics()
if self.logic then
self:logic()
end
self.lastvelocity = self.object:get_velocity()
self.time_total=self.time_total+self.dtime
end,
logic = function(self)
local accel_y = self.object:get_acceleration().y
local rotation = self.object:get_rotation()
local yaw = rotation.y
local curr_pos = self.object:get_pos()
local newyaw
local newpitch
local hull_direction = core.yaw_to_dir(yaw)
local nhdir = {x=hull_direction.z,y=0,z=-hull_direction.x} -- lateral unit vector
local velocity = self.object:get_velocity()
local wind_speed = airutils.get_wind(curr_pos, 0.15)
local longit_speed = steampunk_blimp.dot(velocity,hull_direction)
self._longit_speed = longit_speed --for anchor verify
local relative_longit_speed = longit_speed
if steampunk_blimp.wind_enabled then
relative_longit_speed = steampunk_blimp.dot(vector.add(velocity, wind_speed), hull_direction)
end
self._relative_longit_speed = relative_longit_speed
local longit_drag = vector.multiply(hull_direction,relative_longit_speed*
relative_longit_speed*LONGIT_DRAG_FACTOR*-1*steampunk_blimp.sign(relative_longit_speed))
local later_speed = steampunk_blimp.dot(velocity,nhdir)
local later_drag = vector.multiply(nhdir,later_speed*later_speed*
LATER_DRAG_FACTOR*-1*steampunk_blimp.sign(later_speed))
local accel = vector.add(longit_drag,later_drag)
self._last_pos = curr_pos
self.object:move_to(curr_pos)
if self.owner == "" then return end
--fire
if self.fire then
if self._engine_running == true then
self.fire:set_properties({textures={steampunk_blimp.fire_tex},glow=15})
else
self.fire:set_properties({textures={"steampunk_blimp_alpha.png"},glow=0})
end
end
--detect collision
steampunk_blimp.testDamage(self, velocity, curr_pos)
accel = steampunk_blimp.control(self, self.dtime, hull_direction, relative_longit_speed, accel) or velocity
--get disconnected players
steampunk_blimp.rescueConnectionFailedPassengers(self)
local turn_rate = math.rad(18)
newyaw = yaw + self.dtime*(1 - 1 / (math.abs(relative_longit_speed) + 1)) *
self._rudder_angle / 30 * turn_rate * steampunk_blimp.sign(relative_longit_speed)
steampunk_blimp.engine_step(self, accel)
--roll adjust
---------------------------------
local sdir = core.yaw_to_dir(newyaw)
local snormal = {x=sdir.z,y=0,z=-sdir.x} -- rightside, dot is negative
local prsr = steampunk_blimp.dot(snormal,nhdir)
local rollfactor = -15
local newroll = 0
if self._last_roll ~= nil then newroll = self._last_roll end
--oscilation when stoped
if relative_longit_speed == 0 then
local time_correction = (self.dtime/steampunk_blimp.ideal_step)
--stoped
if self._roll_state == nil then
self._roll_state = math.floor(math.random(-1,1))
if self._roll_state == 0 then self._roll_state = 1 end
self._last_roll = newroll
end
if math.deg(newroll) >= 1 and self._roll_state == 1 then
self._roll_state = -1
steampunk_blimp.play_rope_sound(self);
end
if math.deg(newroll) <= -1 and self._roll_state == -1 then
self._roll_state = 1
steampunk_blimp.play_rope_sound(self);
end
local roll_factor = (self._roll_state * 0.005) * time_correction
self._last_roll = self._last_roll + math.rad(roll_factor)
else
--in movement
self._roll_state = nil
newroll = (prsr*math.rad(rollfactor))*later_speed
if self._last_roll ~= nil then
if math.sign(newroll) ~= math.sign(self._last_roll) then
steampunk_blimp.play_rope_sound(self)
end
end
self._last_roll = newroll
end
--core.chat_send_all('newroll: '.. newroll)
---------------------------------
-- end roll
if steampunk_blimp.wind_enabled then
--local wind_yaw = core.dir_to_yaw(wind_speed)
--core.chat_send_all("x: "..wind_speed.x.. " - z: "..wind_speed.z.." - yaw: "..math.deg(wind_yaw).. " - orig: "..wind_yaw)
if self.anchored == false and self.isonground == false then
accel = vector.add(accel, wind_speed)
else
accel = vector.new()
end
end
accel.y = accel_y
newpitch = velocity.y * math.rad(1.5) * (relative_longit_speed/3)
--self.object:set_acceleration(accel)
self.object:add_velocity(vector.multiply(accel,self.dtime))
self.object:set_rotation({x=newpitch,y=newyaw,z=newroll})
local compass_angle = newyaw
local rem_obj = self.object:get_attach()
if rem_obj then
compass_angle = rem_obj:get_rotation().y
end
self.object:set_bone_position("low_rudder", {x=0,y=0,z=0}, {x=0,y=self._rudder_angle,z=0})
self.object:set_bone_position("rudder", {x=0,y=97,z=-148}, {x=0,y=self._rudder_angle,z=0})
self.object:set_bone_position("timao", {x=0,y=27,z=-25}, {x=0,y=0,z=self._rudder_angle*8})
self.object:set_bone_position("compass_axis", {x=0,y=30.2,z=-21.243}, {x=0, y=(math.deg(compass_angle)), z=0})
--saves last velocy for collision detection (abrupt stop)
self._last_vel = self.object:get_velocity()
self._last_accell = accel
steampunk_blimp.move_persons(self)
end,
on_punch = function(self, puncher, ttime, toolcaps, dir, damage)
if not puncher or not puncher:is_player() then
return
end
local is_admin
is_admin = core.check_player_privs(puncher, {server=true})
local name = puncher:get_player_name()
if self.owner == nil then
self.owner = name
end
local is_attached = steampunk_blimp.checkAttach(self, puncher)
local itmstck=puncher:get_wielded_item()
local item_name = ""
if itmstck then item_name = itmstck:get_name() end
--core.chat_send_all(item_name)
if is_attached == true then
--refuel
if steampunk_blimp.load_fuel(self, puncher) then return end
if steampunk_blimp.load_water(self, puncher) then return end
end
if self.owner and self.owner ~= name and self.owner ~= "" then
if is_admin == false then return end
end
if self.driver_name and self.driver_name ~= name then
-- do not allow other players to remove the object while there is a driver
return
end
-- deal with painting or destroying
if itmstck then
--core.chat_send_all(dump(item_name))
local find_str = 'dye:'
if airutils.is_mcl and not core.get_modpath("mcl_playerplus") then
--mineclonia
find_str = 'mcl_dyes:'
end
local _,indx = item_name:find(find_str)
if indx then
--lets paint!!!!
local color = nil
if not airutils.is_repixture then
color = item_name:sub(indx+1)
end
local colstr = steampunk_blimp.colors[color]
--core.chat_send_all(color ..' '.. dump(colstr))
if colstr and (name == self.owner or core.check_player_privs(puncher, {protection_bypass=true})) then
local ctrl = puncher:get_player_control()
if ctrl.aux1 then
steampunk_blimp.paint2(self, colstr)
else
steampunk_blimp.paint(self, colstr)
end
itmstck:set_count(itmstck:get_count()-1)
puncher:set_wielded_item(itmstck)
end
-- end painting
end
end
if is_attached == false then
local has_passengers = false
for i = steampunk_blimp.max_seats,1,-1
do
if self._passengers[i] ~= nil then
has_passengers = true
break
end
end
if not has_passengers and toolcaps and toolcaps.damage_groups and
toolcaps.groupcaps and (toolcaps.groupcaps.choppy or toolcaps.groupcaps.axey_dig) then
local is_empty = true
--airutils.make_sound(self,'hit')
if is_empty == true then
self.hp = self.hp - 10
core.sound_play("steampunk_blimp_collision", {
object = self.object,
max_hear_distance = 5,
gain = 1.0,
fade = 0.0,
pitch = 1.0,
})
end
end
if self.hp <= 0 then
steampunk_blimp.destroy(self, false)
end
end
end,
on_rightclick = function(self, clicker)
if not clicker or not clicker:is_player() then
return
end
local name = clicker:get_player_name()
if self.owner == "" then
self.owner = name
end
--core.chat_send_all('passengers: '.. dump(self._passengers))
--=========================
-- form to pilot
--=========================
local is_attached = false
local seat = clicker:get_attach()
if seat then
local plane = seat:get_attach()
if plane == self.object then is_attached = true end
end
--check error after being shot for any other mod
if is_attached == false then
for i = steampunk_blimp.max_seats,1,-1
do
if self._passengers[i] == name then
self._passengers[i] = nil --clear the wrong information
break
end
end
end
--shows pilot formspec
if name == self.driver_name then
if is_attached then
steampunk_blimp.pilot_formspec(name)
else
self.driver_name = nil
end
--=========================
-- attach passenger
--=========================
else
local pass_is_attached = steampunk_blimp.check_passenger_is_attached(self, name)
if pass_is_attached then
local can_bypass = core.check_player_privs(clicker, {protection_bypass=true})
if clicker:get_player_control().aux1 == true then --lets see the inventory
local is_shared = false
if name == self.owner or can_bypass then is_shared = true end
for k, v in pairs(self._shared_owners) do
if v == name then
is_shared = true
break
end
end
if is_shared then
airutils.show_vehicle_trunk_formspec(self, clicker, steampunk_blimp.trunk_slots)
end
else
if self.driver_name ~= nil and self.driver_name ~= "" then
--lets take the control by force
if name == self.owner or can_bypass then
--require the pilot position now
steampunk_blimp.owner_formspec(name)
else
steampunk_blimp.pax_formspec(name)
end
else
--check if is on owner list
local is_shared = false
if name == self.owner or can_bypass then is_shared = true end
for k, v in pairs(self._shared_owners) do
if v == name then
is_shared = true
break
end
end
--normal user
if is_shared == false then
steampunk_blimp.pax_formspec(name)
else
--owners
steampunk_blimp.pilot_formspec(name)
end
end
end
else
--first lets clean the boat slots
--note that when it happens, the "rescue" function will lost the historic
for i = steampunk_blimp.max_seats,1,-1
do
if self._passengers[i] ~= nil then
local old_player = core.get_player_by_name(self._passengers[i])
if not old_player then self._passengers[i] = nil end
end
end
--attach normal passenger
--if self._door_closed == false then
steampunk_blimp.attach_pax(self, clicker)
--end
end
end
end,
on_deactivate = airutils.on_deactivate,
})

View file

@ -0,0 +1,623 @@
function steampunk_blimp.getPlaneFromPlayer(player)
local seat = player:get_attach()
if seat then
local plane = seat:get_attach()
return plane
end
return nil
end
function steampunk_blimp.pilot_formspec(name)
local basic_form = table.concat({
"formspec_version[5]",
"size[6,9]",
}, "")
local player = minetest.get_player_by_name(name)
local plane_obj = steampunk_blimp.getPlaneFromPlayer(player)
if plane_obj == nil then
return
end
local ent = plane_obj:get_luaentity()
local take_control = "false"
if ent._at_control then take_control = "true" end
local anchor = "false"
if ent.anchored == true then anchor = "true" end
basic_form = basic_form.."button[1,1.0;4,1;turn_on;Start/Stop the fire]"
basic_form = basic_form.."button[1,2.0;4,1;water;Load water from below]"
if ent._remove ~= true then
basic_form = basic_form.."button[1,3.0;4,1;inventory;Open inventory]"
end
basic_form = basic_form.."button[1,4.0;4,1;manual;Show Manual Menu]"
basic_form = basic_form.."checkbox[1,5.6;take_control;Take the Control;"..take_control.."]"
basic_form = basic_form.."checkbox[1,6.2;anchor;Anchor away;"..anchor.."]"
basic_form = basic_form.."label[1,7.0;Disembark:]"
basic_form = basic_form.."button[1,7.2;2,1;disembark_l;<< Left]"
basic_form = basic_form.."button[3,7.2;2,1;disembark_r;Right >>]"
minetest.show_formspec(name, "steampunk_blimp:pilot_main", basic_form)
end
function steampunk_blimp.pax_formspec(name)
local basic_form = table.concat({
"formspec_version[3]",
"size[6,3]",
}, "")
basic_form = basic_form.."label[1,1.0;Disembark:]"
basic_form = basic_form.."button[1,1.2;2,1;disembark_l;<< Left]"
basic_form = basic_form.."button[3,1.2;2,1;disembark_r;Right >>]"
minetest.show_formspec(name, "steampunk_blimp:passenger_main", basic_form)
end
local default_logos = {
"blimp_clover.png",
"blimp_liz.png",
"blimp_shotting_star.png",
"blimp_skull.png",
"blimp_jack.png",
"blimp_xmas.png",
}
function steampunk_blimp.logo_ext_formspec(name, t_index, t_page, t_type)
t_index = t_index or 1
t_page = t_page or 1
t_type = t_type or 1
if airutils.isTextureLoaded then
airutils.isTextureLoaded('heart.png') --force the textures first load
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> you are using an old version of airutils, update it first"))
return
end
local basic_form = table.concat({
"formspec_version[4]",
"size[12,9]",
}, "")
local textures = {}
if t_type == "1" or t_type == 1 then textures = airutils.properties_copy(default_logos) end
if t_type == "2" or t_type == 2 then textures = airutils.properties_copy(airutils.all_game_textures) end
if t_type == "3" or t_type == 3 then textures = airutils.properties_copy(airutils.all_entities_textures) end
if t_type == "4" or t_type == 4 then textures = airutils.properties_copy(airutils.all_items_textures) end
local text_count = #textures
local items_per_page = 50
local pages = math.ceil(text_count / items_per_page)
local logolist = ""
local items_count = 0
local item_start = ((t_page-1)*items_per_page) + 1
for k, v in pairs(textures) do
if k >= item_start and items_count < items_per_page then
logolist = logolist .. v .. ","
items_count = items_count + 1
end
if items_count >= items_per_page then break end
end
local pages_list = ""
for i = 1,pages,1
do
pages_list = pages_list .. i .. ","
end
basic_form = basic_form.."label[0.5,0.9;Type]"
basic_form = basic_form.."dropdown[2,0.5;3,0.8;t_type;Default,Nodes,Entities,Items;"..t_type..";true]"
basic_form = basic_form.."textlist[0.5,1.5;4.5,6;logos;"..logolist..";"..t_index..";false]"
local curr_real_index = (items_per_page * (t_page-1)) + t_index
local texture_name = textures[curr_real_index] or ""
basic_form = basic_form.."image[5.5,1.5;6,6;"..texture_name.."]"
basic_form = basic_form.."label[0.6,8.2;Page]"
basic_form = basic_form.."dropdown[1.8,7.8;1.9,0.8;t_page;"..pages_list..";"..t_page..";true]"
basic_form = basic_form.."button[8.5,7.8;3,0.8;set_texture;Set Texture]"
basic_form = basic_form.."field[5.3,20.0;3,0.8;texture_name;;"..texture_name.."]"
basic_form = basic_form.."field[5.3,21.0;3,0.8;last_type;;"..t_type.."]"
minetest.show_formspec(name, "steampunk_blimp:logo_ext", basic_form)
end
function steampunk_blimp.owner_formspec(name)
local basic_form = table.concat({
"formspec_version[3]",
"size[6,4.2]",
}, "")
basic_form = basic_form.."button[1,1.0;4,1;take;Take the Control Now]"
basic_form = basic_form.."label[1,2.2;Disembark:]"
basic_form = basic_form.."button[1,2.4;2,1;disembark_l;<< Left]"
basic_form = basic_form.."button[3,2.4;2,1;disembark_r;Right >>]"
minetest.show_formspec(name, "steampunk_blimp:owner_main", basic_form)
end
function set_list(list)
local set = {}
for _, l in ipairs(list) do set[l] = true end
return set
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname == "steampunk_blimp:owner_main" then
local name = player:get_player_name()
local plane_obj = steampunk_blimp.getPlaneFromPlayer(player)
if plane_obj == nil then
minetest.close_formspec(name, "steampunk_blimp:owner_main")
return
end
local ent = plane_obj:get_luaentity()
if ent then
if fields.disembark_l then
steampunk_blimp.dettach_pax(ent, player, "l")
end
if fields.disembark_r then
steampunk_blimp.dettach_pax(ent, player, "r")
end
if fields.take then
ent._at_control = true
for i = 5,1,-1
do
if ent._passengers[i] == name then
ent._passengers_base_pos[i] = vector.new(steampunk_blimp.pilot_base_pos)
ent._passengers_base[i]:set_attach(ent.object,'',steampunk_blimp.pilot_base_pos,{x=0,y=0,z=0})
player:set_attach(ent._passengers_base[i], "", {x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
end
if ent._passengers[i] == ent.driver_name then
ent._passengers_base_pos[i] = vector.new(steampunk_blimp.passenger_pos[i])
ent._passengers_base[i]:set_attach(ent.object,'',ent._passengers_base_pos[i],{x=0,y=0,z=0})
end
end
ent.driver_name = name
end
end
minetest.close_formspec(name, "steampunk_blimp:owner_main")
end
if formname == "steampunk_blimp:passenger_main" then
local name = player:get_player_name()
local plane_obj = steampunk_blimp.getPlaneFromPlayer(player)
if plane_obj == nil then
minetest.close_formspec(name, "steampunk_blimp:passenger_main")
return
end
local ent = plane_obj:get_luaentity()
if ent then
if fields.disembark_l then
steampunk_blimp.dettach_pax(ent, player, "l")
end
if fields.disembark_r then
steampunk_blimp.dettach_pax(ent, player, "r")
end
end
minetest.close_formspec(name, "steampunk_blimp:passenger_main")
end
if formname == "steampunk_blimp:logo_ext" then
local name = player:get_player_name()
local plane_obj = steampunk_blimp.getPlaneFromPlayer(player)
if plane_obj == nil then
minetest.close_formspec(name, "steampunk_blimp:logo_ext")
return
end
local ent = plane_obj:get_luaentity()
if ent then
if fields.set_texture then
if ent.name == "steampunk_blimp:blimp" then
if ent.owner == name or minetest.check_player_privs(name, {protection_bypass=true}) then
if fields.texture_name then
local image_name = fields.texture_name
local logo_list = set_list(default_logos)
if airutils.isTextureLoaded(image_name) or logo_list[image_name] then
steampunk_blimp.set_logo(ent, image_name)
minetest.chat_send_player(name,core.colorize('#00ff00', " >>> texture '"..image_name.."' set"))
--minetest.close_formspec(name, "steampunk_blimp:logo_ext")
return
end
end
end
end
end
if fields.logos or fields.t_page then
--minetest.close_formspec(name, "steampunk_blimp:logo_ext")
--steampunk_blimp.logo_ext_formspec(name,fields.logos)
local result = minetest.explode_textlist_event(fields.logos)
if result.type == "CHG" then
--minetest.chat_send_all(dump(result.index))
--minetest.close_formspec(name, "steampunk_blimp:logo_ext")
steampunk_blimp.logo_ext_formspec(name,result.index,fields.t_page,fields.last_type)
return
end
steampunk_blimp.logo_ext_formspec(name,1,fields.t_page,fields.last_type)
return
end
if fields.t_type then
steampunk_blimp.logo_ext_formspec(name,1,1,fields.t_type)
return
end
end
end
if formname == "steampunk_blimp:pilot_main" then
local name = player:get_player_name()
local plane_obj = steampunk_blimp.getPlaneFromPlayer(player)
if plane_obj == nil then
minetest.close_formspec(name, "steampunk_blimp:pilot_main")
return
end
local ent = plane_obj:get_luaentity()
if ent then
if fields.turn_on then
steampunk_blimp.start_furnace(ent)
end
if fields.water then
if ent.isinliquid then
if ent._engine_running == true then
steampunk_blimp.start_furnace(ent)
end
if ent._boiler_pressure > 0 then
minetest.sound_play({name = "default_cool_lava"},
{object = ent.object, gain = 1.0,
pitch = 1.0,
max_hear_distance = 32,
loop = false,}, true)
end
ent._boiler_pressure = 0
ent._water_level = steampunk_blimp.MAX_WATER
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> Impossible. The ship needs to be in the water."))
end
end
if fields.inventory then
if ent._remove ~= true then
airutils.show_vehicle_trunk_formspec(ent, player, steampunk_blimp.trunk_slots)
end
end
if fields.manual then
steampunk_blimp.manual_formspec(name)
end
if fields.take_control then
if fields.take_control == "true" then
if ent.driver_name == nil or ent.driver_name == "" then
ent._at_control = true
for i = steampunk_blimp.max_seats,1,-1
do
if ent._passengers[i] == name then
ent._passengers_base_pos[i] = vector.new(steampunk_blimp.pilot_base_pos)
ent._passengers_base[i]:set_attach(ent.object,'',steampunk_blimp.pilot_base_pos,{x=0,y=0,z=0})
player:set_attach(ent._passengers_base[i], "", {x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
ent.driver_name = name
--minetest.chat_send_all(">>"..ent.driver_name)
break
end
end
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> Impossible. Someone is at the blimp control now."))
end
else
ent.driver_name = nil
ent._at_control = false
steampunk_blimp.remove_hud(player)
end
end
if fields.disembark_l then
--=========================
-- dettach player
--=========================
-- eject passenger if the plane is on ground
steampunk_blimp.dettach_pax(ent, player, "l")
end
if fields.disembark_r then
--=========================
-- dettach player
--=========================
-- eject passenger if the plane is on ground
steampunk_blimp.dettach_pax(ent, player, "r")
end
if fields.anchor then
if fields.anchor == "true" then
local max_speed_anchor = 0.6
if ent._longit_speed then
if math.abs(ent._longit_speed) < max_speed_anchor then
ent.anchored = true
ent.object:set_acceleration(vector.new())
ent.object:set_velocity(vector.new())
if name then
minetest.chat_send_player(name,core.colorize('#00ff00', " >>> Anchor away!"))
end
--ent.buoyancy = 0.1
else
if name then
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> Too fast to set anchor!"))
end
end
end
else
ent.anchored = false
if name then
minetest.chat_send_player(name,core.colorize('#00ff00', " >>> Weigh anchor!"))
end
end
--ent._rudder_angle = 0
end
end
minetest.close_formspec(name, "steampunk_blimp:pilot_main")
end
end)
minetest.register_chatcommand("blimp_share", {
params = "name",
description = "Share ownewrship with your friends",
privs = {interact = true},
func = function(name, param)
local player = minetest.get_player_by_name(name)
local target_player = minetest.get_player_by_name(param)
local attached_to = player:get_attach()
if attached_to ~= nil and target_player ~= nil then
local seat = attached_to:get_attach()
if seat ~= nil then
local entity = seat:get_luaentity()
if entity then
if entity.name == "steampunk_blimp:blimp" then
if entity.owner == name then
local exists = false
for k, v in pairs(entity._shared_owners) do
if v == param then
exists = true
break
end
end
if exists == false then
table.insert(entity._shared_owners, param)
minetest.chat_send_player(name,core.colorize('#00ff00', " >>> blimp shared"))
--minetest.chat_send_all(dump(entity._shared_owners))
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> this user is already registered for blimp share"))
end
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> only the owner can share this blimp"))
end
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> you are not inside a blimp to perform this command"))
end
end
end
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> you are not inside a blimp to perform this command"))
end
end
})
minetest.register_chatcommand("blimp_remove", {
params = "name",
description = "Removes ownewrship from someone",
privs = {interact = true},
func = function(name, param)
local player = minetest.get_player_by_name(name)
local attached_to = player:get_attach()
if attached_to ~= nil then
local seat = attached_to:get_attach()
if seat ~= nil then
local entity = seat:get_luaentity()
if entity then
if entity.name == "steampunk_blimp:blimp" then
if entity.owner == name then
for k, v in pairs(entity._shared_owners) do
if v == param then
table.remove(entity._shared_owners,k)
break
end
end
minetest.chat_send_player(name,core.colorize('#00ff00', " >>> user removed"))
--minetest.chat_send_all(dump(entity._shared_owners))
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> only the owner can do this action"))
end
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> you are not inside a blimp to perform this command"))
end
end
end
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> you are not inside a blimp to perform this command"))
end
end
})
minetest.register_chatcommand("blimp_list", {
params = "",
description = "Lists the blimp shared owners",
privs = {interact = true},
func = function(name, param)
local player = minetest.get_player_by_name(name)
local attached_to = player:get_attach()
if attached_to ~= nil then
local seat = attached_to:get_attach()
if seat ~= nil then
local entity = seat:get_luaentity()
if entity then
if entity.name == "steampunk_blimp:blimp" then
minetest.chat_send_player(name,core.colorize('#ffff00', " >>> Current owners are:"))
minetest.chat_send_player(name,core.colorize('#0000ff', entity.owner))
for k, v in pairs(entity._shared_owners) do
minetest.chat_send_player(name,core.colorize('#00ff00', v))
end
--minetest.chat_send_all(dump(entity._shared_owners))
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> you are not inside a blimp to perform this command"))
end
end
end
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> you are not inside a blimp to perform this command"))
end
end
})
minetest.register_chatcommand("blimp_lock", {
params = "true/false",
description = "Blocks boarding of non-owners. true to lock, false to unlock",
privs = {interact = true},
func = function(name, param)
local player = minetest.get_player_by_name(name)
local attached_to = player:get_attach()
if attached_to ~= nil then
local seat = attached_to:get_attach()
if seat ~= nil then
local entity = seat:get_luaentity()
if entity then
if entity.name == "steampunk_blimp:blimp" then
if param == "true" then
entity._passengers_locked = true
minetest.chat_send_player(name,core.colorize('#ffff00', " >>> Non owners cannot enter now."))
elseif param == "false" then
entity._passengers_locked = false
minetest.chat_send_player(name,core.colorize('#00ff00', " >>> Non owners are free to enter now."))
end
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> you are not inside a blimp to perform this command"))
end
end
end
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> you are not inside a blimp to perform this command"))
end
end
})
minetest.register_chatcommand("blimp_logo", {
params = "<image_name.png>",
description = "Changes blimp logo",
privs = {interact = true},
func = function(name, param)
local image_name = param --"blimp_alpha.png^"..param
local colorstring = core.colorize('#ff0000', " >>> you are not inside a blimp")
local player = minetest.get_player_by_name(name)
local attached_to = player:get_attach()
if attached_to ~= nil then
local seat = attached_to:get_attach()
if seat ~= nil then
local entity = seat:get_luaentity()
if entity then
if entity.name == "steampunk_blimp:blimp" then
if entity.owner == name or minetest.check_player_privs(name, {protection_bypass=true}) then
if airutils.isTextureLoaded then
if param == '' then
steampunk_blimp.logo_ext_formspec(name)
else
local logo_list = set_list(default_logos)
if airutils.isTextureLoaded(image_name) or logo_list[image_name] then
steampunk_blimp.set_logo(entity, image_name)
minetest.chat_send_player(name,core.colorize('#00ff00', " >>> texture '"..image_name.."' set"))
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> texture '"..image_name.."' not found"))
end
end
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> you are using an old version of airutils, update it first"))
end
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> only the owner can do this action"))
end
else
minetest.chat_send_player(name,colorstring)
end
end
end
else
minetest.chat_send_player(name,colorstring)
end
end
})
minetest.register_chatcommand("blimp_eject", {
params = "",
description = "Ejects from the blimp - useful for clients before 5.3",
privs = {interact = true},
func = function(name, param)
local colorstring = core.colorize('#ff0000', " >>> you are not inside a blimp")
local player = minetest.get_player_by_name(name)
local attached_to = player:get_attach()
if attached_to ~= nil then
local seat = attached_to:get_attach()
if seat ~= nil then
local entity = seat:get_luaentity()
if entity then
if entity.name == "steampunk_blimp:blimp" then
for i = steampunk_blimp.max_seats,1,-1
do
if entity._passengers[i] == name then
steampunk_blimp.dettach_pax(entity, player, "l")
break
end
end
else
minetest.chat_send_player(name,colorstring)
end
end
end
else
minetest.chat_send_player(name,colorstring)
end
end
})
if airutils.is_repixture then
local available_text = "The available colors are: black, blue, brown, cyan, dark_green, dark_grey, green, grey, magenta, orange, pink, red, violet, white or yellow"
minetest.register_chatcommand("blimp_paint", {
params = "<color1> <color2>",
description = "Paints the blimp with a primary and secondary colors. "..available_text,
privs = {interact = true},
func = function(name, param)
local colorstring = core.colorize('#ff0000', " >>> you are not inside a blimp")
local player = minetest.get_player_by_name(name)
local attached_to = player:get_attach()
if attached_to ~= nil then
local seat = attached_to:get_attach()
if seat ~= nil then
local entity = seat:get_luaentity()
if entity then
if entity.name == "steampunk_blimp:blimp" then
if entity.owner == name or minetest.check_player_privs(name, {protection_bypass=true}) then
--lets paint!!!!
local color1, color2 = param:match("^([%a%d_-]+) (.+)$")
--minetest.chat_send_all(dump(color1).." - "..dump(color2))
local colstr = steampunk_blimp.colors[color1]
local colstr2 = steampunk_blimp.colors[color2 or "white"]
--minetest.chat_send_all(color ..' '.. dump(colstr))
if colstr and colstr2 then
steampunk_blimp.paint2(entity, colstr)
steampunk_blimp.paint(entity, colstr2)
minetest.chat_send_player(name,core.colorize('#00ff00', " >>> colors set successfully"))
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> some of the colors wasn't specified correctly. "..available_text))
end
else
minetest.chat_send_player(name,core.colorize('#ff0000', " >>> only the owner can do this action"))
end
else
minetest.chat_send_player(name,colorstring)
end
end
end
else
minetest.chat_send_player(name,colorstring)
end
end
})
end

View file

@ -0,0 +1,97 @@
--
-- fuel
--
steampunk_blimp.MAX_FUEL = minetest.settings:get("steampunk_blimp_max_fuel") or 99
steampunk_blimp.FUEL_CONSUMPTION = minetest.settings:get("steampunk_blimp_fuel_consumption") or 6000
steampunk_blimp.MAX_WATER = 10
steampunk_blimp.WATER_CONSUMPTION = 50000
function steampunk_blimp.contains(table, val)
for k,v in pairs(table) do
if k == val then
return v
end
end
return false
end
function steampunk_blimp.load_fuel(self, player)
local inv = player:get_inventory()
local itmstck=player:get_wielded_item()
local item_name = ""
if itmstck then item_name = itmstck:get_name() end
local grp_wood = minetest.get_item_group(item_name, "wood")
local grp_tree = minetest.get_item_group(item_name, "tree")
if grp_wood == 1 or grp_tree == 1 then
local stack = ItemStack(item_name .. " 1")
if self._energy < steampunk_blimp.MAX_FUEL then
inv:remove_item("main", stack)
local amount = 1
if grp_tree == 1 then amount = 4 end
self._energy = self._energy + amount
if self._energy > steampunk_blimp.MAX_FUEL then self._energy = steampunk_blimp.MAX_FUEL end
end
return true
end
--minetest.chat_send_all("fuel: ".. dump(item_name))
local fuel = steampunk_blimp.contains(steampunk_blimp.fuel, item_name)
if fuel then
local stack = ItemStack(item_name .. " 1")
if self._energy < steampunk_blimp.MAX_FUEL then
inv:remove_item("main", stack)
self._energy = self._energy + fuel.amount
if self._energy > steampunk_blimp.MAX_FUEL then self._energy = steampunk_blimp.MAX_FUEL end
--minetest.chat_send_all(self.energy)
--local energy_indicator_angle = steampunk_blimp.get_pointer_angle(self._energy, steampunk_blimp.MAX_FUEL)
end
return true
end
return false
end
function steampunk_blimp.load_water(self, player)
--local inv = player:get_inventory()
local itmstck=player:get_wielded_item()
local item_name = ""
if itmstck then item_name = itmstck:get_name() end
--minetest.chat_send_all("water: ".. dump(item_name))
local water = steampunk_blimp.contains(steampunk_blimp.water, item_name)
if water then
if self._water_level < steampunk_blimp.MAX_WATER then
local itemstack
--itmstck:set_count(1)
--inv:remove_item("main", itmstck)
local bucket_name = 'bucket:bucket'
if airutils.is_mcl then bucket_name = "mcl_buckets:bucket" end
if airutils.is_repixture then bucket_name = "rp_default:bucket_" end
local indx = item_name:find(bucket_name)
if indx then
itemstack = ItemStack(bucket_name.."_empty")
--inv:add_item("main", itemstack)
player:set_wielded_item(itemstack)
end
if not itemstack then
itemstack = ItemStack(item_name .. " 1")
end
self._water_level = self._water_level + water.amount
if self._water_level > steampunk_blimp.MAX_WATER then self._water_level = steampunk_blimp.MAX_WATER end
end
return true
end
return false
end

View file

@ -0,0 +1,253 @@
steampunk_blimp.hud_list = {}
function steampunk_blimp.get_pointer_angle(value, maxvalue)
local angle = value/maxvalue * 180
--angle = angle - 90
--angle = angle * -1
return angle
end
function steampunk_blimp.animate_gauge(player, ids, prefix, x, y, angle)
local angle_in_rad = math.rad(angle + 180)
local dim = 10
local pos_x = math.sin(angle_in_rad) * dim
local pos_y = math.cos(angle_in_rad) * dim
player:hud_change(ids[prefix .. "2"], "offset", {x = pos_x + x, y = pos_y + y})
dim = 20
pos_x = math.sin(angle_in_rad) * dim
pos_y = math.cos(angle_in_rad) * dim
player:hud_change(ids[prefix .. "3"], "offset", {x = pos_x + x, y = pos_y + y})
dim = 30
pos_x = math.sin(angle_in_rad) * dim
pos_y = math.cos(angle_in_rad) * dim
player:hud_change(ids[prefix .. "4"], "offset", {x = pos_x + x, y = pos_y + y})
dim = 40
pos_x = math.sin(angle_in_rad) * dim
pos_y = math.cos(angle_in_rad) * dim
player:hud_change(ids[prefix .. "5"], "offset", {x = pos_x + x, y = pos_y + y})
dim = 50
pos_x = math.sin(angle_in_rad) * dim
pos_y = math.cos(angle_in_rad) * dim
player:hud_change(ids[prefix .. "6"], "offset", {x = pos_x + x, y = pos_y + y})
dim = 60
pos_x = math.sin(angle_in_rad) * dim
pos_y = math.cos(angle_in_rad) * dim
player:hud_change(ids[prefix .. "7"], "offset", {x = pos_x + x, y = pos_y + y})
end
function steampunk_blimp.update_hud(player, coal, water, pressure, power_lever)
if player == nil then return end
local player_name = player:get_player_name()
local screen_pos_y = -100
local screen_pos_x = 10
local water_gauge_x = screen_pos_x + 374
local water_gauge_y = screen_pos_y
local press_gauge_x = screen_pos_x + 85
local press_gauge_y = water_gauge_y
local coal_1_x = screen_pos_x + 182
local coal_1_y = screen_pos_y
local coal_2_x = coal_1_x + 60
local coal_2_y = screen_pos_y
local throttle_x = screen_pos_x + 395
local throttle_y = screen_pos_y + 45
local ids = steampunk_blimp.hud_list[player_name]
if ids then
local coal_value = coal
if coal_value > 99 then coal_value = 99 end
if coal_value < 0 then coal_value = 0 end
player:hud_change(ids["coal_1"], "text", "steampunk_blimp_"..(math.floor(coal_value/10))..".png")
player:hud_change(ids["coal_2"], "text", "steampunk_blimp_"..(math.floor(coal_value%10))..".png")
player:hud_change(ids["throttle"], "offset", {x = throttle_x, y = throttle_y - power_lever})
steampunk_blimp.animate_gauge(player, ids, "water_pt_", water_gauge_x, water_gauge_y, water)
steampunk_blimp.animate_gauge(player, ids, "press_pt_", press_gauge_x, press_gauge_y, pressure)
else
ids = {}
ids["title"] = player:hud_add({
hud_elem_type = "text",
position = {x = 0, y = 1},
offset = {x = screen_pos_x + 240, y = screen_pos_y - 100},
text = "Blimp engine state",
alignment = 0,
scale = { x = 100, y = 30},
number = 0xFFFFFF,
})
ids["bg"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = screen_pos_x, y = screen_pos_y},
text = "steampunk_blimp_hud_panel.png",
scale = { x = 0.5, y = 0.5},
alignment = { x = 1, y = 0 },
})
ids["coal_1"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = coal_1_x, y = coal_1_y},
text = "steampunk_blimp_0.png",
scale = { x = 0.5, y = 0.5},
alignment = { x = 1, y = 0 },
})
ids["coal_2"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = coal_2_x, y = coal_2_y},
text = "steampunk_blimp_0.png",
scale = { x = 0.5, y = 0.5},
alignment = { x = 1, y = 0 },
})
ids["throttle"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = throttle_x, y = throttle_y},
text = "steampunk_blimp_throttle.png",
scale = { x = 0.5, y = 0.5},
alignment = { x = 1, y = 0 },
})
ids["water_pt_1"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = water_gauge_x, y = water_gauge_y},
text = "steampunk_blimp_ind_box.png",
scale = { x = 6, y = 6},
alignment = { x = 1, y = 0 },
})
ids["water_pt_2"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = water_gauge_x, y = water_gauge_y},
text = "steampunk_blimp_ind_box.png",
scale = { x = 6, y = 6},
alignment = { x = 1, y = 0 },
})
ids["water_pt_3"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = water_gauge_x, y = water_gauge_y},
text = "steampunk_blimp_ind_box.png",
scale = { x = 6, y = 6},
alignment = { x = 1, y = 0 },
})
ids["water_pt_4"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = water_gauge_x, y = water_gauge_y},
text = "steampunk_blimp_ind_box.png",
scale = { x = 6, y = 6},
alignment = { x = 1, y = 0 },
})
ids["water_pt_5"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = water_gauge_x, y = water_gauge_y},
text = "steampunk_blimp_ind_box.png",
scale = { x = 6, y = 6},
alignment = { x = 1, y = 0 },
})
ids["water_pt_6"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = water_gauge_x, y = water_gauge_y},
text = "steampunk_blimp_ind_box.png",
scale = { x = 6, y = 6},
alignment = { x = 1, y = 0 },
})
ids["water_pt_7"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = water_gauge_x, y = water_gauge_y},
text = "steampunk_blimp_ind_box.png",
scale = { x = 6, y = 6},
alignment = { x = 1, y = 0 },
})
ids["press_pt_1"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = press_gauge_x, y = press_gauge_y},
text = "steampunk_blimp_ind_box.png",
scale = { x = 6, y = 6},
alignment = { x = 1, y = 0 },
})
ids["press_pt_2"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = press_gauge_x, y = press_gauge_y},
text = "steampunk_blimp_ind_box.png",
scale = { x = 6, y = 6},
alignment = { x = 1, y = 0 },
})
ids["press_pt_3"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = press_gauge_x, y = press_gauge_y},
text = "steampunk_blimp_ind_box.png",
scale = { x = 6, y = 6},
alignment = { x = 1, y = 0 },
})
ids["press_pt_4"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = press_gauge_x, y = press_gauge_y},
text = "steampunk_blimp_ind_box.png",
scale = { x = 6, y = 6},
alignment = { x = 1, y = 0 },
})
ids["press_pt_5"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = press_gauge_x, y = press_gauge_y},
text = "steampunk_blimp_ind_box.png",
scale = { x = 6, y = 6},
alignment = { x = 1, y = 0 },
})
ids["press_pt_6"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = press_gauge_x, y = press_gauge_y},
text = "steampunk_blimp_ind_box.png",
scale = { x = 6, y = 6},
alignment = { x = 1, y = 0 },
})
ids["press_pt_7"] = player:hud_add({
hud_elem_type = "image",
position = {x = 0, y = 1},
offset = {x = press_gauge_x, y = press_gauge_y},
text = "steampunk_blimp_ind_box.png",
scale = { x = 6, y = 6},
alignment = { x = 1, y = 0 },
})
steampunk_blimp.hud_list[player_name] = ids
end
end
function steampunk_blimp.remove_hud(player)
if player then
local player_name = player:get_player_name()
--minetest.chat_send_all(player_name)
local ids = steampunk_blimp.hud_list[player_name]
--minetest.chat_send_all(dump(ids))
if ids then
--player:hud_remove(ids["altitude"])
--player:hud_remove(ids["time"])
for key in pairs(ids) do
player:hud_remove(ids[key])
end
steampunk_blimp.hud_list[player_name] = nil
end
end
end

View file

@ -0,0 +1,459 @@
steampunk_blimp={}
steampunk_blimp.gravity = tonumber(minetest.settings:get("movement_gravity")) or 9.8
steampunk_blimp.trunk_slots = 50
steampunk_blimp.fuel = {['default:coal_lump'] = {amount=1},['default:coalblock'] = {amount=10}, ['rp_default:lump_coal'] = {amount=1}, ['rp_default:block_coal'] = {amount=10},
['mcl_core:coal_lump'] = {amount=1},['mcl_core:coalblock'] = {amount=10}, ['default:coal_lump'] = {amount=1}, ['default:coalblock'] = {amount=10}}
steampunk_blimp.water = {['default:water_source'] = {amount=1},['default:river_water_source'] = {amount=1},
['bucket:bucket_water'] = {amount=1}, ['bucket:bucket_river_water'] = {amount=1},
['mcl_buckets:bucket_water'] = {amount=1}, ['mcl_buckets:bucket_river_water'] = {amount=1}, ['mcl_core:water_source'] = {amount=1},
['rp_default:bucket_water'] = {amount=1}, ['rp_default:bucket_river_water'] = {amount=1}, } --bucket:bucket_empty
steampunk_blimp.ideal_step = 0.02
steampunk_blimp.rudder_limit = 30
steampunk_blimp.iddle_rotation = 0
steampunk_blimp.max_engine_acc = 3
steampunk_blimp.max_seats = 7
steampunk_blimp.wind_enabled = false
steampunk_blimp.pilot_base_pos = {x=0.0,y=20.821,z=-30}
steampunk_blimp.passenger_pos = {
[1] = {x=0.0,y=0,z=-15},
[2] = {x=-11,y=0,z=-12},
[3] = {x=11,y=0,z=-12},
[4] = {x=-11,y=0,z=14},
[5] = {x=11,y=0,z=14},
[6] = {x=-11,y=0,z=13},
[7] = {x=11,y=0,z=13},
}
steampunk_blimp.furnace_sound = { name = "default_furnace_active", pitch = 1.0, gain = 0.2 }
steampunk_blimp.piston_sound = { name = "default_cool_lava", pitch = 0.4, gain = 0.05 }
steampunk_blimp.steps_sound = { name = "default_wood_footstep", pitch = 1.0, gain = 0.1 }
if airutils.is_mcl then
steampunk_blimp.furnace_sound = { name = "fire_fire", pitch = 1.0, gain = 0.2 }
elseif airutils.is_repixture then
steampunk_blimp.furnace_sound = nil
steampunk_blimp.piston_sound = { name = "rp_default_torch_burnout", pitch = 0.3, gain = 0.15 }
steampunk_blimp.steps_sound = { name = "rp_sounds_footstep_wood", pitch = 1.0, gain = 0.5 }
end
if airutils.is_repixture then
steampunk_blimp.color1_texture = "rp_default_reed_block_side.png"
steampunk_blimp.color2_texture = "rp_default_reed_block_top.png"
steampunk_blimp.fire_tex = "[combine:16x16:0,0=steampunk_blimp_alpha.png:0,0=rp_fire_bonfire_flame.png" --"rp_fire_bonfire_flame.png^[resize:16x16"
steampunk_blimp.canvas_texture = "mobs_wool.png^[colorize:#f4e7c1:128"
steampunk_blimp.metal_texture = "default_sand.png^[colorize:#a3acac:128"
steampunk_blimp.black_texture = "default_sand.png^[colorize:#030303:200"
steampunk_blimp.wood_texture = "default_sand.png^[colorize:#3a270d:230"
steampunk_blimp.forno_texture = steampunk_blimp.black_texture.."^[mask:steampunk_blimp_forno_mask.png"
steampunk_blimp.rotor_texture = "("..steampunk_blimp.canvas_texture.."^[mask:steampunk_blimp_rotor_mask2.png)^(default_wood_oak.png^[mask:steampunk_blimp_rotor_mask.png)"
local ladder_texture = "default_ladder.png"
steampunk_blimp.textures = {
steampunk_blimp.black_texture, --alimentacao balao
"default_wood_oak.png", --asa
steampunk_blimp.canvas_texture, --asa
steampunk_blimp.canvas_texture, --balao
steampunk_blimp.color2_texture, --faixas brancas nariz
steampunk_blimp.color1_texture, --faixas azuis nariz
steampunk_blimp.metal_texture, --pontas do balão
"airutils_name_canvas.png",
steampunk_blimp.black_texture, --caldeira
steampunk_blimp.forno_texture, --caldeira
"default_wood_oak.png^[multiply:#A09090", --casco
steampunk_blimp.black_texture, -- corpo da bussola
steampunk_blimp.metal_texture, -- indicador bussola
steampunk_blimp.canvas_texture, --leme
"default_wood_oak.png^[multiply:#A09090", --leme
steampunk_blimp.wood_texture, --timao
"steampunk_blimp_compass.png",
ladder_texture, --escada
"default_wood_oak.png", --mureta
steampunk_blimp.wood_texture, --mureta
steampunk_blimp.black_texture, --nacele rotores
steampunk_blimp.wood_texture, --quilha
"default_wood_oak.png", --rotores
steampunk_blimp.rotor_texture, --"steampunk_blimp_rotor.png", --rotores
steampunk_blimp.black_texture, --suportes rotores
"default_wood_oak.png^[multiply:#A09090", --suporte timao
"steampunk_blimp_rope.png", --cordas
steampunk_blimp.color1_texture, --det azul
steampunk_blimp.color2_texture, --det branco
steampunk_blimp.wood_texture, --fixacao cordas
"steampunk_blimp_alpha_logo.png", --logo
}
else
steampunk_blimp.color1_texture = "wool_blue.png"
steampunk_blimp.color2_texture = "wool_yellow.png"
steampunk_blimp.fire_tex = "default_furnace_fire_fg.png"
steampunk_blimp.canvas_texture = "wool_white.png^[colorize:#f4e7c1:128"
steampunk_blimp.metal_texture = "default_clay.png^[colorize:#a3acac:128"
steampunk_blimp.black_texture = "default_clay.png^[colorize:#030303:200"
steampunk_blimp.wood_texture = "default_clay.png^[colorize:#3a270d:230"
steampunk_blimp.forno_texture = steampunk_blimp.black_texture.."^[mask:steampunk_blimp_forno_mask.png"
steampunk_blimp.rotor_texture = "("..steampunk_blimp.canvas_texture.."^[mask:steampunk_blimp_rotor_mask2.png)^(default_wood.png^[mask:steampunk_blimp_rotor_mask.png)"
local ladder_texture = "default_ladder_wood.png"
if airutils.is_mcl then ladder_texture = "default_ladder.png" end
steampunk_blimp.textures = {
steampunk_blimp.black_texture, --alimentacao balao
"default_wood.png", --asa
steampunk_blimp.canvas_texture, --asa
steampunk_blimp.canvas_texture, --balao
steampunk_blimp.color2_texture, --faixas brancas nariz
steampunk_blimp.color1_texture, --faixas azuis nariz
steampunk_blimp.metal_texture, --pontas do balão
"airutils_name_canvas.png",
steampunk_blimp.black_texture, --caldeira
steampunk_blimp.forno_texture, --caldeira
"default_junglewood.png", --casco
steampunk_blimp.black_texture, -- corpo da bussola
steampunk_blimp.metal_texture, -- indicador bussola
steampunk_blimp.canvas_texture, --leme
"default_junglewood.png", --leme
steampunk_blimp.wood_texture, --timao
"steampunk_blimp_compass.png",
ladder_texture, --escada
"default_wood.png", --mureta
steampunk_blimp.wood_texture, --mureta
steampunk_blimp.black_texture, --nacele rotores
steampunk_blimp.wood_texture, --quilha
"default_wood.png", --rotores
steampunk_blimp.rotor_texture, --"steampunk_blimp_rotor.png", --rotores
steampunk_blimp.black_texture, --suportes rotores
"default_junglewood.png", --suporte timao
"steampunk_blimp_rope.png", --cordas
steampunk_blimp.color1_texture, --det azul
steampunk_blimp.color2_texture, --det branco
steampunk_blimp.wood_texture, --fixacao cordas
"steampunk_blimp_alpha_logo.png", --logo
--"steampunk_blimp_metal.png",
--"steampunk_blimp_red.png",
}
end
steampunk_blimp.colors ={
black='black',
blue='blue',
brown='brown',
cyan='cyan',
dark_green='dark_green',
dark_grey='dark_grey',
green='green',
grey='grey',
magenta='magenta',
orange='orange',
pink='pink',
red='red',
violet='violet',
white='white',
yellow='yellow',
}
dofile(minetest.get_modpath("steampunk_blimp") .. DIR_DELIM .. "walk_map.lua")
dofile(minetest.get_modpath("steampunk_blimp") .. DIR_DELIM .. "utilities.lua")
dofile(minetest.get_modpath("steampunk_blimp") .. DIR_DELIM .. "control.lua")
dofile(minetest.get_modpath("steampunk_blimp") .. DIR_DELIM .. "fuel_management.lua")
dofile(minetest.get_modpath("steampunk_blimp") .. DIR_DELIM .. "engine_management.lua")
dofile(minetest.get_modpath("steampunk_blimp") .. DIR_DELIM .. "custom_physics.lua")
dofile(minetest.get_modpath("steampunk_blimp") .. DIR_DELIM .. "hud.lua")
dofile(minetest.get_modpath("steampunk_blimp") .. DIR_DELIM .. "entities.lua")
dofile(minetest.get_modpath("steampunk_blimp") .. DIR_DELIM .. "forms.lua")
dofile(minetest.get_modpath("steampunk_blimp") .. DIR_DELIM .. "manual.lua")
--
-- helpers and co.
--
function steampunk_blimp.get_hipotenuse_value(point1, point2)
return math.sqrt((point1.x - point2.x) ^ 2 + (point1.y - point2.y) ^ 2 + (point1.z - point2.z) ^ 2)
end
function steampunk_blimp.dot(v1,v2)
return v1.x*v2.x+v1.y*v2.y+v1.z*v2.z
end
function steampunk_blimp.sign(n)
return n>=0 and 1 or -1
end
function steampunk_blimp.minmax(v,m)
return math.min(math.abs(v),m)*steampunk_blimp.sign(v)
end
-----------
-- items
-----------
-- blimp
minetest.register_tool("steampunk_blimp:blimp", {
description = "Steampunk Blimp",
inventory_image = "steampunk_blimp_icon.png",
liquids_pointable = true,
stack_max = 1,
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return
end
local stack_meta = itemstack:get_meta()
local staticdata = stack_meta:get_string("staticdata")
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+3
local blimp = minetest.add_entity(pointed_pos, "steampunk_blimp:blimp", staticdata)
if blimp and placer then
local ent = blimp:get_luaentity()
ent._passengers = steampunk_blimp.copy_vector({[1]=nil, [2]=nil, [3]=nil, [4]=nil, [5]=nil, [6]=nil, [7]=nil})
--minetest.chat_send_all('passengers: '.. dump(ent._passengers))
local owner = placer:get_player_name()
ent.owner = owner
ent.hp = 50 --reset hp
blimp:set_yaw(placer:get_look_horizontal())
itemstack:take_item()
airutils.create_inventory(ent, steampunk_blimp.trunk_slots, owner)
local properties = ent.object:get_properties()
properties.infotext = owner .. " nice blimp"
blimp:set_properties(properties)
--steampunk_blimp.attach_pax(ent, placer)
end
return itemstack
end,
})
-- ephemeral blimp
minetest.register_craftitem("steampunk_blimp:ephemeral_blimp", {
description = "Ephemeral Blimp",
inventory_image = "steampunk_blimp_ephemeral_icon.png",
liquids_pointable = true,
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+3
local blimp = minetest.add_entity(pointed_pos, "steampunk_blimp:blimp")
if blimp and placer then
local ent = blimp:get_luaentity()
ent._passengers = steampunk_blimp.copy_vector({[1]=nil, [2]=nil, [3]=nil, [4]=nil, [5]=nil, [6]=nil, [7]=nil})
--minetest.chat_send_all('passengers: '.. dump(ent._passengers))
local owner = placer:get_player_name()
ent.owner = owner
ent._remove = true
ent._water_level = steampunk_blimp.MAX_WATER --start it full loaded
ent._energy = steampunk_blimp.MAX_FUEL --start it full loaded
ent._vehicle_name = "Ephemeral Blimp",
steampunk_blimp.paint(ent, "orange")
blimp:set_yaw(placer:get_look_horizontal())
itemstack:take_item()
local properties = ent.object:get_properties()
properties.infotext = owner .. " nice blimp"
blimp:set_properties(properties)
--steampunk_blimp.attach_pax(ent, placer)
end
return itemstack
end,
})
if minetest.settings:get_bool('steampunk_blimp.enable_wind') then
steampunk_blimp.wind_enabled = true
else
steampunk_blimp.wind_enabled = false
end
--
-- crafting
--
if not minetest.settings:get_bool('steampunk_blimp.disable_craftitems') then
local item_name = "steampunk_blimp:cylinder_part"
if airutils.is_repixture then
crafting.register_craft({
output = item_name,
items = {
"group:fuzzy 8",
"rp_default:stick 4",
"group:planks 1",
}
})
elseif airutils.is_mcl then
minetest.register_craft({
output = item_name,
recipe = {
{"mcl_core:stick", "mcl_wool:white", "mcl_core:stick"},
{"mcl_wool:white", "mcl_core:wood", "mcl_wool:white"},
{"mcl_core:stick", "mcl_wool:white", "mcl_core:stick"},
}
})
else
minetest.register_craft({
output = item_name,
recipe = {
{"default:stick", "wool:white", "default:stick"},
{"wool:white", "group:wood", "wool:white"},
{"default:stick", "wool:white", "default:stick"},
}
})
end
item_name = "steampunk_blimp:cylinder"
if airutils.is_repixture then
crafting.register_craft({
output = item_name,
items = {
"steampunk_blimp:cylinder_part 3",
}
})
else
minetest.register_craft({
output = item_name,
recipe = {
{"steampunk_blimp:cylinder_part", "steampunk_blimp:cylinder_part", "steampunk_blimp:cylinder_part"},
}
})
end
item_name = "steampunk_blimp:rotor"
if airutils.is_repixture then
crafting.register_craft({
output = item_name,
items = {
"group:fuzzy 3",
"rp_default:stick 3",
"rp_default:block_wrought_iron 1",
}
})
elseif airutils.is_mcl then
minetest.register_craft({
output = item_name,
recipe = {
{"mcl_wool:white", "mcl_core:stick", ""},
{"mcl_wool:white", "mcl_core:stick", "mcl_core:ironblock"},
{"mcl_wool:white", "mcl_core:stick", ""},
}
})
else
minetest.register_craft({
output = item_name,
recipe = {
{"wool:white", "default:stick", ""},
{"wool:white", "default:stick", "default:steelblock"},
{"wool:white", "default:stick", ""},
}
})
end
item_name = "steampunk_blimp:boiler"
if airutils.is_repixture then
crafting.register_craft({
output = item_name,
items = {
"rp_default:ingot_wrought_iron 4",
"rp_default:block_wrought_iron 2",
}
})
elseif airutils.is_mcl then
minetest.register_craft({
output = item_name,
recipe = {
{"mcl_core:iron_ingot","mcl_core:iron_ingot"},
{"mcl_core:ironblock","mcl_core:iron_ingot",},
{"mcl_core:ironblock","mcl_core:iron_ingot"},
}
})
else
minetest.register_craft({
output = item_name,
recipe = {
{"default:steel_ingot","default:steel_ingot"},
{"default:steelblock","default:steel_ingot",},
{"default:steelblock","default:steel_ingot"},
}
})
end
item_name = "steampunk_blimp:boat"
if airutils.is_repixture then
crafting.register_craft({
output = item_name,
items = {
"group:planks 6",
"steampunk_blimp:rotor 2",
"steampunk_blimp:boiler 1",
}
})
else
minetest.register_craft({
output = item_name,
recipe = {
{"group:wood", "group:wood", "steampunk_blimp:rotor"},
{"group:wood", "steampunk_blimp:boiler", "group:wood"},
{"group:wood", "group:wood", "steampunk_blimp:rotor"},
}
})
end
item_name = "steampunk_blimp:blimp"
if airutils.is_repixture then
crafting.register_craft({
output = item_name,
items = {
"steampunk_blimp:cylinder 1",
"steampunk_blimp:boat 1",
}
})
else
minetest.register_craft({
output = item_name,
recipe = {
{"steampunk_blimp:cylinder",},
{"steampunk_blimp:boat",},
}
})
end
-- cylinder section
minetest.register_craftitem("steampunk_blimp:cylinder_part",{
description = "steampunk_blimp cylinder section",
inventory_image = "steampunk_blimp_cylinder_part.png",
})
-- cylinder
minetest.register_craftitem("steampunk_blimp:cylinder",{
description = "steampunk_blimp cylinder",
inventory_image = "steampunk_blimp_cylinder.png",
})
-- boiler
minetest.register_craftitem("steampunk_blimp:boiler",{
description = "steampunk_blimp boiler",
inventory_image = "steampunk_blimp_boiler.png",
})
-- boiler
minetest.register_craftitem("steampunk_blimp:rotor",{
description = "steampunk_blimp rotor",
inventory_image = "steampunk_blimp_rotor.png",
})
-- fuselage
minetest.register_craftitem("steampunk_blimp:boat",{
description = "steampunk_blimp fuselage",
inventory_image = "steampunk_blimp_boat.png",
})
end

View file

@ -0,0 +1,91 @@
--------------
-- Manual --
--------------
function steampunk_blimp.manual_formspec(name)
local basic_form = table.concat({
"formspec_version[3]",
"size[6,6]"
}, "")
basic_form = basic_form.."button[1,1.0;4,1;short;Shortcuts]"
basic_form = basic_form.."button[1,2.5;4,1;fuel;Refueling]"
basic_form = basic_form.."button[1,4.0;4,1;share;Sharing]"
minetest.show_formspec(name, "steampunk_blimp:manual_main", basic_form)
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname == "steampunk_blimp:manual_main" then
local formspec_color = "#44444466"
if fields.short then
local text = {
"Shortcuts \n\n",
"* Right click: enter in / acess the internal menu \n",
"* Punch with dye to paint the primary color\n",
"* Punch a dye, but holding Aux (E) key to change the secondary color.\n",
"* To change the blimp logo, call the command \""..core.colorize('#ffff00', "/blimp_logo").."\".\n",
"* Forward or backward while in drive position: controls the power lever \n",
"* Left or right while in drive position: controls the direction \n",
"* Jump and sneak: controls the up and down movement \n",
"* Aux (E) + right click while inside: acess inventory \n",
"* Aux (E) + backward while in drive position: the machine does backward \n",
"* Aux (E) + foward while in drive position: extra power \n"
}
local shortcut_form = table.concat({
"formspec_version[3]",
"size[16,10]",
"no_prepend[]",
"bgcolor["..formspec_color..";false]",
"label[1.0,2.0;", table.concat(text, ""), "]",
}, "")
minetest.show_formspec(player:get_player_name(), "steampunk_blimp:manual_shortcut", shortcut_form)
end
if fields.fuel then
local text = {
"Fuel \n\n",
"To fly it, it is necessary to provide some items, such as fuel to be burned and \n",
"water for the boiler. The fuel can be coal, coal block or wood. To supply it, \n",
"be on board and punch the necessary items on the airship.\n",
"There is another way to load water to the boiler: if it is landed on water, it can load \n",
"it through the menu. But the current pressure will be lost. \n"
}
local fuel_form = table.concat({
"formspec_version[3]",
"size[16,10]",
"no_prepend[]",
"bgcolor["..formspec_color..";false]",
"label[1.0,2.0;", table.concat(text, ""), "]",
}, "")
minetest.show_formspec(player:get_player_name(), "steampunk_blimp:fuel", fuel_form)
end
if fields.share then
local text = {
"Sharing \n\n",
"This vehicle was made to be shared with a team. So the owner can set more users to \n",
"operate it. Inside the blimp, just use the command \""..core.colorize('#ffff00', "/blimp_share <name>").."\" \n",
"To remove someone from the sharing, \""..core.colorize('#ffff00', "/blimp_remove <name>").."\" \n",
"To list the owners, \""..core.colorize('#ffff00', "/blimp_list").."\" \n",
"Is possible to lock the blimp access, so only the owners can enter: \""..core.colorize('#ffff00', "/blimp_lock true").."\" \n",
"To let anyone enter, \""..core.colorize('#ffff00', "/blimp_lock false").."\" \n",
"All shared owners can access the blimp inventory"
}
local tips_form = table.concat({
"formspec_version[3]",
"size[16,10]",
"no_prepend[]",
"bgcolor["..formspec_color..";false]",
"label[1,2;", table.concat(text, ""), "]",
}, "")
minetest.show_formspec(player:get_player_name(), "steampunk_blimp:share", tips_form)
end
end
end)
minetest.register_chatcommand("blimp_manual", {
params = "",
description = "Blimp manual",
func = function(name, param)
steampunk_blimp.manual_formspec(name)
end
})

View file

@ -0,0 +1,7 @@
name = steampunk_blimp
depends = airutils
optional_depends = rp_crafting
author = apercy
description = Adds a steampunk blimp
title = Steampunk Blimp
release = 30012

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,6 @@
#!/bin/bash
# Colors with 0 alpha need to be preserved, because opaque leaves ignore alpha.
# For that purpose, the use of indexed colors is disabled (-nc).
find -name 'textures/*.png' -print0 | xargs -0 optipng -o7 -zm1-9 -nc -strip all -clobber

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View file

@ -0,0 +1,505 @@
function steampunk_blimp.testDamage(self, velocity, position)
if self._last_accell == nil then return end
local p = position --self.object:get_pos()
local collision = false
local low_node_pos = -2.5
if self._last_vel == nil then return end
--lets calculate the vertical speed, to avoid the bug on colliding on floor with hard lag
if math.abs(velocity.y - self._last_vel.y) > 2 then
local noded = airutils.nodeatpos(airutils.pos_shift(p,{y=low_node_pos}))
if (noded and noded.drawtype ~= 'airlike') then
collision = true
else
self.object:set_velocity(self._last_vel)
--self.object:set_acceleration(self._last_accell)
self.object:set_velocity(vector.add(velocity, vector.multiply(self._last_accell, self.dtime/8)))
end
end
local impact = math.abs(steampunk_blimp.get_hipotenuse_value(velocity, self._last_vel))
if impact > 2 then
if self.colinfo then
collision = self.colinfo.collides
--core.chat_send_all(impact)
end
end
if collision then
--self.object:set_velocity({x=0,y=0,z=0})
local damage = impact -- / 2
core.sound_play("steampunk_blimp_collision", {
--to_player = self.driver_name,
object = self.object,
max_hear_distance = 15,
gain = 1.0,
fade = 0.0,
pitch = 1.0,
}, true)
if damage > 5 then
self._power_lever = 0
end
if self.driver_name then
local player_name = self.driver_name
local player = core.get_player_by_name(player_name)
if player then
if player:get_hp() > 0 then
player:set_hp(player:get_hp()-(damage/2))
end
end
if self._passenger ~= nil then
local passenger = core.get_player_by_name(self._passenger)
if passenger then
if passenger:get_hp() > 0 then
passenger:set_hp(passenger:get_hp()-(damage/2))
end
end
end
end
end
end
local function do_attach(self, player, slot)
if slot == 0 then return end
if self._passengers[slot] == nil then
local name = player:get_player_name()
--core.chat_send_all(self.driver_name)
self._passengers[slot] = name
player:set_attach(self._passengers_base[slot], "", {x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
if airutils.is_mcl then
mcl_player.player_attached[name] = true
elseif airutils.is_repixture then
rp_player.player_attached[name] = true
else
player_api.player_attached[name] = true
end
end
end
function steampunk_blimp.check_passenger_is_attached(self, name)
local is_attached = false
if is_attached == false then
for i = steampunk_blimp.max_seats,1,-1
do
if self._passengers[i] == name then
is_attached = true
break
end
end
end
return is_attached
end
--this method checks each 1 second for a disconected player who comes back
function steampunk_blimp.rescueConnectionFailedPassengers(self)
self._disconnection_check_time = self._disconnection_check_time + self.dtime
if self._disconnection_check_time > 1 then
--core.chat_send_all(dump(self._passengers))
self._disconnection_check_time = 0
for i = steampunk_blimp.max_seats,1,-1
do
if self._passengers[i] then
local player = core.get_player_by_name(self._passengers[i])
if player then --we have a player!
local is_attached = nil
if airutils.is_mcl then
is_attached = mcl_player.player_attached[self._passengers[i]]
elseif airutils.is_repixture then
is_attached = rp_player.player_attached[self._passengers[i]]
else
is_attached = player_api.player_attached[self._passengers[i]]
end
if is_attached == nil then --but isn't attached?
--core.chat_send_all("okay")
if player:get_hp() > 0 then
self._passengers[i] = nil --clear the slot first
do_attach(self, player, i) --attach
end
end
end
end
end
end
end
-- attach passenger
function steampunk_blimp.attach_pax(self, player, slot)
slot = slot or 0
--verify if is locked to non-owners
if self._passengers_locked == true then
local name = player:get_player_name()
local can_bypass = core.check_player_privs(player, {protection_bypass=true})
local is_shared = false
if name == self.owner or can_bypass then is_shared = true end
for k, v in pairs(self._shared_owners) do
if v == name then
is_shared = true
break
end
end
if is_shared == false then
core.chat_send_player(name,core.colorize('#ff0000', " >>> This blimp is currently locked for non-owners"))
return
end
end
if slot > 0 then
do_attach(self, player, slot)
return
end
--core.chat_send_all(dump(self._passengers))
--now yes, lets attach the player
--randomize the seat
local t = {1,2,3,4,5,6,7}
for i = 1, #t*2 do
local a = math.random(#t)
local b = math.random(#t)
t[a],t[b] = t[b],t[a]
end
--core.chat_send_all(dump(t))
for k,v in ipairs(t) do
local i = t[k] or 0
if self._passengers[i] == nil then
do_attach(self, player, i)
--core.chat_send_all(i)
break
end
end
end
function steampunk_blimp.dettach_pax(self, player, side)
side = side or "r"
if player then
local name = player:get_player_name() --self._passenger
if self.driver_name == name then
self.driver_name = nil
self._at_control = false
end
steampunk_blimp.remove_hud(player)
-- passenger clicked the object => driver gets off the vehicle
for i = steampunk_blimp.max_seats,1,-1
do
if self._passengers[i] == name then
self._passengers[i] = nil
self._passengers_base_pos[i] = steampunk_blimp.copy_vector(steampunk_blimp.passenger_pos[i])
--break
end
end
-- detach the player
player:set_detach()
if airutils.is_mcl then
mcl_player.player_attached[name] = nil
mcl_player.player_set_animation(player, "stand", 30)
elseif airutils.is_repixture then
rp_player.player_attached[name] = nil
rp_player.player_set_animation(player, "stand", 30)
else
player_api.player_attached[name] = nil
player_api.set_animation(player, "stand")
end
-- move player down
core.after(0.1, function(pos)
local rotation = self.object:get_rotation()
local direction = rotation.y
if side == "l" then
direction = direction - math.rad(180)
end
local move = 5
pos.x = pos.x + move * math.cos(direction)
pos.z = pos.z + move * math.sin(direction)
if self.isinliquid then
pos.y = pos.y + 1
else
pos.y = pos.y - 2.5
end
player:set_pos(pos)
end, player:get_pos())
end
end
function steampunk_blimp.textures_copy()
local tablecopy = {}
for k, v in pairs(steampunk_blimp.textures) do
tablecopy[k] = v
end
return tablecopy
end
--this function needs an urgent refactory to be independent, but not today :(
local function paint(self, write_prefix)
write_prefix = write_prefix or false
local l_textures = steampunk_blimp.textures_copy()
for _, texture in ipairs(l_textures) do
local indx = texture:find(steampunk_blimp.color1_texture)
if indx then
if not airutils.is_repixture then
l_textures[_] = "wool_".. self.color..".png"
else
l_textures[_] = "rp_default_reed_block_side.png^[colorize:"..airutils.colors[self.color]
end
end
indx = texture:find(steampunk_blimp.color2_texture)
if indx then
if not airutils.is_repixture then
l_textures[_] = "wool_".. self.color2..".png"
else
l_textures[_] = "rp_default_reed_block_side.png^[colorize:"..airutils.colors[self.color2]
end
end
indx = texture:find('steampunk_blimp_alpha_logo.png')
if indx then
l_textures[_] = self.logo
end
if airutils._use_signs_api and write_prefix == true then
indx = texture:find('airutils_name_canvas.png')
if indx then
l_textures[_] = "airutils_name_canvas.png^"..airutils.convert_text_to_texture(self._ship_name, self._name_color or 0, self._name_hor_aligment or 0.8)
end
end
end
self.object:set_properties({textures=l_textures})
end
function steampunk_blimp.set_logo(self, texture_name)
if texture_name == "" or texture_name == nil then
self.logo = "steampunk_blimp_alpha_logo.png"
elseif texture_name then
self.logo = texture_name
end
paint(self)
end
--painting
function steampunk_blimp.paint(self, colstr)
if colstr then
self.color = colstr
paint(self)
end
end
function steampunk_blimp.paint2(self, colstr)
if colstr then
self.color2 = colstr
paint(self,true)
end
end
-- destroy the boat
function steampunk_blimp.destroy(self, overload)
if self.sound_handle then
core.sound_stop(self.sound_handle)
self.sound_handle = nil
end
local pos = self.object:get_pos()
if self.fire then self.fire:remove() end
for i = steampunk_blimp.max_seats,1,-1
do
if self._passengers_base[i] then self._passengers_base[i]:remove() end
end
airutils.destroy_inventory(self)
self.inv = nil
self._inv_id = nil
local remove_it = self._remove or false
local lua_ent = self.object:get_luaentity()
local staticdata = lua_ent:get_staticdata(self)
local player = core.get_player_by_name(self.owner)
self.object:remove()
if remove_it == false then
pos.y=pos.y+2
--[[for i=1,7 do
core.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'default:steel_ingot')
end
for i=1,7 do
core.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'default:mese_crystal')
end]]--
--core.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'steampunk_blimp:boat')
--core.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'default:diamond')
local stack = ItemStack(self.item)
local stack_meta = stack:get_meta()
stack_meta:set_string("staticdata", staticdata)
if player then
local inv = player:get_inventory()
if inv then
if inv:room_for_item("main", stack) then
inv:add_item("main", stack)
else
core.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5}, stack)
end
end
else
core.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5}, stack)
end
end
end
--returns 0 for old, 1 for new
function steampunk_blimp.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
function steampunk_blimp.checkAttach(self, player)
local retVal = false
if player then
local player_attach = player:get_attach()
if player_attach then
for i = steampunk_blimp.max_seats,1,-1
do
if player_attach == self._passengers_base[i] then
retVal = true
break
end
end
end
end
return retVal
end
function steampunk_blimp.clamp(value, min, max)
local retVal = value
if value < min then retVal = min end
if value > max then retVal = max end
--core.chat_send_all(value .. " - " ..retVal)
return retVal
end
function steampunk_blimp.reclamp(value, min, max)
local retVal = value
local mid = (max-min)/2
if value > min and value <= (min+mid) then retVal = min end
if value < max and value > (max-mid) then retVal = max end
--core.chat_send_all(value .. " - return: " ..retVal .. " - mid: " .. mid)
return retVal
end
function steampunk_blimp.engineSoundPlay(self)
--sound
if self.sound_handle then core.sound_stop(self.sound_handle) end
if self.sound_handle_pistons then core.sound_stop(self.sound_handle_pistons) end
if self.object then
local furnace_sound = "default_furnace_active"
if steampunk_blimp.furnace_sound then
self.sound_handle = core.sound_play({name = steampunk_blimp.furnace_sound.name},
{object = self.object, gain = steampunk_blimp.furnace_sound.gain,
max_hear_distance = 5,
loop = true,})
end
self.sound_handle_pistons = core.sound_play({name = steampunk_blimp.piston_sound.name},--"default_item_smoke"},
{object = self.object, gain = steampunk_blimp.piston_sound.gain,
pitch = steampunk_blimp.piston_sound.pitch+((math.abs(self._power_lever)/100)/2),
max_hear_distance = 32,
loop = true,})
end
end
function steampunk_blimp.engine_set_sound_and_animation(self)
if self._last_applied_power ~= self._power_lever then
--core.chat_send_all('test2')
self._last_applied_power = self._power_lever
self.object:set_animation_frame_speed(steampunk_blimp.iddle_rotation + (self._power_lever))
if self._last_sound_update == nil then self._last_sound_update = self._power_lever end
if math.abs(self._last_sound_update - self._power_lever) > 5 then
self._last_sound_update = self._power_lever
steampunk_blimp.engineSoundPlay(self)
end
end
if self._engine_running == false then
if self.sound_handle then
core.sound_stop(self.sound_handle)
self.sound_handle = nil
--self.object:set_animation_frame_speed(0)
end
end
end
function steampunk_blimp.start_furnace(self)
if self._engine_running then
self._engine_running = false
-- sound and animation
if self.sound_handle then
core.sound_stop(self.sound_handle)
self.sound_handle = nil
end
elseif self._engine_running == false and self._energy > 0 then
self._engine_running = true
-- sound
if self.sound_handle then core.sound_stop(self.sound_handle) end
if self.object then
local furnace_sound = "default_furnace_active"
if airutils.is_mcl then furnace_sound = "fire_fire" end
if steampunk_blimp.furnace_sound then
self.sound_handle = core.sound_play({name = steampunk_blimp.furnace_sound.name},
{object = self.object, gain = steampunk_blimp.furnace_sound.gain,
max_hear_distance = 5,
loop = true,})
end
end
end
end
function steampunk_blimp.copy_vector(original_vector)
local tablecopy = {}
for k, v in pairs(original_vector) do
tablecopy[k] = v
end
return tablecopy
end
function steampunk_blimp.play_rope_sound(self)
core.sound_play({name = "steampunk_blimp_rope"},
{object = self.object, gain = 1,
max_hear_distance = 5,
ephemeral = true,})
end
function steampunk_blimp.table_copy(table_here)
local tablecopy = {}
for k, v in pairs(table_here) do
tablecopy[k] = v
end
return tablecopy
end

View file

@ -0,0 +1,312 @@
function steampunk_blimp.clamp(value, min, max)
local retVal = value
if value < min then retVal = min end
if value > max then retVal = max end
--minetest.chat_send_all(value .. " - " ..retVal)
return retVal
end
function steampunk_blimp.reclamp(value, min, max)
local retVal = value
local mid = (max-min)/2
if value > min and value <= (min+mid) then retVal = min end
if value < max and value > (max-mid) then retVal = max end
--minetest.chat_send_all(value .. " - return: " ..retVal .. " - mid: " .. mid)
return retVal
end
local function is_obstacle_zone(pos, start_point, end_point)
local retVal = steampunk_blimp.table_copy(pos)
local min_x, min_z, max_x, max_z
if start_point.x <= end_point.x then min_x = start_point.x else min_x = end_point.x end
if start_point.z <= end_point.z then min_z = start_point.z else min_z = end_point.z end
if start_point.x > end_point.x then max_x = start_point.x else max_x = end_point.x end
if start_point.z > end_point.z then max_z = start_point.z else max_z = end_point.z end
local mid_x = (max_x - min_x)/2
local mid_z = (max_z - min_z)/2
if pos.x < max_x and pos.x > min_x+mid_x and
pos.z < max_z and pos.z > min_z then
retVal.x = max_x + 1
return retVal
end
if pos.x > min_x and pos.x <= min_x+mid_x and
pos.z < max_z and pos.z > min_z then
retVal.x = min_x - 1
return retVal
end
local death_zone = 1.5 --to avoid the "slip" when colliding in y direction
if pos.z < max_z + death_zone and pos.z > min_z+mid_z and
pos.x > min_x and pos.x < max_x then
retVal.z = max_z + 1
return retVal
end
if pos.z > min_z - death_zone and pos.z <= min_z+mid_z and
pos.x > min_x and pos.x < max_x then
retVal.z = min_z - 1
return retVal
end
return retVal
end
function steampunk_blimp.boat_upper_deck_map(pos, dpos)
local orig_pos = steampunk_blimp.copy_vector(pos)
local position = steampunk_blimp.copy_vector(dpos)
local new_pos = steampunk_blimp.copy_vector(dpos)
new_pos.z = steampunk_blimp.clamp(new_pos.z, -47, -16)
new_pos = is_obstacle_zone(new_pos, {x=4, z=-28}, {x=-4, z=-20}) --timao
new_pos = is_obstacle_zone(new_pos, {x=-30, z=-24}, {x=4, z=-12})
if position.z >= -49 and position.z < -32 then --limit 10
new_pos.y = 20.821
new_pos.x = steampunk_blimp.clamp(new_pos.x, -8, 8)
return new_pos
end
if position.z >= -32 and position.z < -14 then --limit 11
new_pos.y = 20.821
new_pos.x = steampunk_blimp.clamp(new_pos.x, -11, 11)
if position.z > -24 then --escada
if orig_pos.x <= 4 then
new_pos.z = steampunk_blimp.reclamp(new_pos.z, -24, -12)
end
end
return new_pos
end
return new_pos
end
local function is_ladder_zone(pos)
local ladder_zone = false
if pos.z <= -12 and pos.z >= -18 and pos.x > 4 and pos.x < 12 then ladder_zone = true end
return ladder_zone
end
function steampunk_blimp.boat_lower_deck_map(pos, dpos)
local position = steampunk_blimp.copy_vector(dpos)
local new_pos = steampunk_blimp.copy_vector(dpos)
new_pos.z = steampunk_blimp.clamp(new_pos.z, -29, 45)
if position.z > -31 and position.z < -14 then --limit 10
new_pos.y = 0
new_pos.x = steampunk_blimp.clamp(new_pos.x, -10, 10)
new_pos = is_obstacle_zone(new_pos, {x=-6, z=-9}, {x=6, z=14}) --caldeira
return new_pos
end
if position.z >= -14 and position.z < -4 then --limit 11
new_pos.y = 0
new_pos.x = steampunk_blimp.clamp(new_pos.x, -12, 12)
new_pos = is_obstacle_zone(new_pos, {x=-6, z=-9}, {x=6, z=14}) --caldeira
return new_pos
end
if position.z >= -4 and position.z <= 4 then --limit 14
new_pos.y = 0
new_pos.x = steampunk_blimp.clamp(position.x, -14, 14)
new_pos = is_obstacle_zone(new_pos, {x=-6, z=-9}, {x=6, z=14}) --caldeira
return new_pos
end
if position.z > 4 and position.z <= 19 then --limit 11
new_pos.y = 0
new_pos.x = steampunk_blimp.clamp(position.x, -12, 12)
new_pos = is_obstacle_zone(new_pos, {x=-6, z=-9}, {x=6, z=14}) --caldeira
return new_pos
end
if position.z > 19 and position.z <= 22 then --limit 10
new_pos.y = 4.4
new_pos.x = steampunk_blimp.clamp(new_pos.x, -10, 10)
return new_pos
end
if position.z > 22 and position.z <= 30 then --limit 7
new_pos.y = 8.5
new_pos.x = steampunk_blimp.clamp(new_pos.x, -7, 7)
return new_pos
end
if position.z > 30 and position.z <= 36 then --limit 5
new_pos.y = 8.5
new_pos.x = steampunk_blimp.clamp(new_pos.x, -5, 5)
return new_pos
end
if position.z > 36 and position.z < 47 then --limit 1
new_pos.y = 8.5
new_pos.x = steampunk_blimp.clamp(new_pos.x, -2, 2)
return new_pos
end
return new_pos
end
function steampunk_blimp.ladder_map(pos, dpos)
local position = steampunk_blimp.copy_vector(dpos)
local new_pos = steampunk_blimp.copy_vector(dpos)
new_pos.z = steampunk_blimp.clamp(new_pos.z, -18, -12)
if position.z > -20 and position.z < -10 then --limit 10
new_pos.x = steampunk_blimp.clamp(new_pos.x, 4, 12)
end
return new_pos
end
function steampunk_blimp.navigate_deck(pos, dpos, player)
local pos_d = dpos
local ladder_zone = is_ladder_zone(pos)
local upper_deck_y = 20.821
local lower_deck_y = 0
if player then
if pos.y == upper_deck_y then
pos_d = steampunk_blimp.boat_upper_deck_map(pos, dpos)
elseif pos.y <= 8.5 and pos.y >= 0 then
if ladder_zone == false then
pos_d = steampunk_blimp.boat_lower_deck_map(pos, dpos)
end
elseif pos.y > 8.5 and pos.y < upper_deck_y then
pos_d = steampunk_blimp.ladder_map(pos, dpos)
end
local ctrl = player:get_player_control()
if ctrl.jump or ctrl.sneak then --ladder
if ladder_zone then
--minetest.chat_send_all(dump(pos))
if ctrl.jump then
pos_d.y = pos_d.y + 0.9
if pos_d.y > upper_deck_y then pos_d.y = upper_deck_y end
end
if ctrl.sneak then
pos_d.y = pos_d.y - 0.9
if pos_d.y < lower_deck_y then pos_d.y = lower_deck_y end
end
end
end
end
--minetest.chat_send_all(dump(pos_d))
return pos_d
end
--note: index variable just for the walk
--this function was improved by Auri Collings on steampumove_personsnk_blimp
local function get_result_pos(self, player, index)
local pos = nil
if player then
local ctrl = player:get_player_control()
local direction = player:get_look_horizontal()
local rotation = self.object:get_rotation()
direction = direction - rotation.y
pos = vector.new()
local y_rot = -math.deg(direction)
pos.y = y_rot --okay, this is strange to keep here, but as I dont use it anyway...
if ctrl.up or ctrl.down or ctrl.left or ctrl.right then
if airutils.is_mcl then
mcl_player.player_set_animation(player, "walk", 30)
elseif airutils.is_repixture then
rp_player.player_set_animation(player, "walk", 30)
else
player_api.set_animation(player, "walk", 30)
end
local speed = 0.4
local dir = vector.new(ctrl.up and -1 or ctrl.down and 1 or 0, 0, ctrl.left and 1 or ctrl.right and -1 or 0)
dir = vector.normalize(dir)
dir = vector.rotate(dir, {x = 0, y = -direction, z = 0})
local time_correction = (self.dtime/steampunk_blimp.ideal_step)
local move = speed * time_correction
pos.x = move * dir.x
pos.z = move * dir.z
--lets fake walk sound
if self._passengers_base_pos[index].dist_moved == nil then self._passengers_base_pos[index].dist_moved = 0 end
self._passengers_base_pos[index].dist_moved = self._passengers_base_pos[index].dist_moved + move;
if math.abs(self._passengers_base_pos[index].dist_moved) > 5 then
self._passengers_base_pos[index].dist_moved = 0
minetest.sound_play({name = steampunk_blimp.steps_sound.name},
{object = player, gain = steampunk_blimp.steps_sound.gain,
max_hear_distance = 5,
ephemeral = true,})
end
else
if airutils.is_mcl then
mcl_player.player_set_animation(player, "stand", 30)
elseif airutils.is_repixture then
rp_player.player_set_animation(player, "stand", 30)
else
player_api.set_animation(player, "stand", 30)
end
end
end
return pos
end
function steampunk_blimp.move_persons(self)
--self._passenger = nil
if self.object == nil then return end
for i = steampunk_blimp.max_seats,1,-1
do
local player = nil
if self._passengers[i] then player = minetest.get_player_by_name(self._passengers[i]) end
if self.driver_name and self._passengers[i] == self.driver_name then
--clean driver if it's nil
if player == nil then
self._passengers[i] = nil
self.driver_name = nil
end
else
if self._passengers[i] ~= nil then
--minetest.chat_send_all("pass: "..dump(self._passengers[i]))
--the rest of the passengers
if player then
if self._passenger_is_sit[i] == 0 then
local result_pos = get_result_pos(self, player, i)
local y_rot = 0
if result_pos then
y_rot = result_pos.y -- the only field that returns a rotation
local new_pos = steampunk_blimp.copy_vector(self._passengers_base_pos[i])
new_pos.x = new_pos.x - result_pos.z
new_pos.z = new_pos.z - result_pos.x
--minetest.chat_send_all(dump(new_pos))
local pos_d = steampunk_blimp.navigate_deck(self._passengers_base_pos[i], new_pos, player)
--minetest.chat_send_all(dump(height))
self._passengers_base_pos[i] = steampunk_blimp.copy_vector(pos_d)
self._passengers_base[i]:set_attach(self.object,'',self._passengers_base_pos[i],{x=0,y=0,z=0})
end
--minetest.chat_send_all(dump(self._passengers_base_pos[i]))
player:set_attach(self._passengers_base[i], "", {x = 0, y = 0, z = 0}, {x = 0, y = y_rot, z = 0})
else
local y_rot = 0
if self._passenger_is_sit[i] == 1 then y_rot = 0 end
if self._passenger_is_sit[i] == 2 then y_rot = 90 end
if self._passenger_is_sit[i] == 3 then y_rot = 180 end
if self._passenger_is_sit[i] == 4 then y_rot = 270 end
player:set_attach(self._passengers_base[i], "", {x = 0, y = 3.6, z = 0}, {x = 0, y = y_rot, z = 0})
airutils.sit(player)
end
end
end
end
end
end