mirror of
https://github.com/APercy/airutils.git
synced 2025-03-15 08:01:22 +00:00
Merge pull request #7 from MoNTE48/patch1
Fix 'Unable to register same mod storage twice' error
This commit is contained in:
commit
e70246f1cb
2 changed files with 28 additions and 26 deletions
26
init.lua
26
init.lua
|
@ -1,8 +1,10 @@
|
|||
-- Minetest 5.4.1 : airutils
|
||||
|
||||
local storage = minetest.get_mod_storage()
|
||||
airutils = {
|
||||
storage = minetest.get_mod_storage()
|
||||
}
|
||||
|
||||
airutils = {}
|
||||
local storage = airutils.storage
|
||||
|
||||
airutils.colors ={
|
||||
black='#2b2b2b',
|
||||
|
@ -174,7 +176,7 @@ local function get_nodedef_field(nodename, fieldname)
|
|||
return minetest.registered_nodes[nodename][fieldname]
|
||||
end
|
||||
|
||||
--for
|
||||
--for
|
||||
function airutils.eval_vertical_interception(initial_pos, end_pos)
|
||||
local ret_y = nil
|
||||
local cast = minetest.raycast(initial_pos, end_pos, true, true)
|
||||
|
@ -211,7 +213,7 @@ end
|
|||
local function lerp(a, b, c)
|
||||
return a + (b - a) * c
|
||||
end
|
||||
|
||||
|
||||
function airutils.quadBezier(t, p0, p1, p2)
|
||||
local l1 = lerp(p0, p1, t)
|
||||
local l2 = lerp(p1, p2, t)
|
||||
|
@ -238,7 +240,7 @@ function airutils.get_ground_effect_lift(self, curr_pos, lift, wingspan)
|
|||
ground_distance = initial_pos.y - ground_y
|
||||
end
|
||||
--minetest.chat_send_all(dump(ground_distance))
|
||||
|
||||
|
||||
--smooth the curve
|
||||
local distance_factor = ((ground_distance) * 1) / (wingspan)
|
||||
local effect_factor = airutils.quadBezier(distance_factor, 0, wingspan, 0)
|
||||
|
@ -246,13 +248,13 @@ function airutils.get_ground_effect_lift(self, curr_pos, lift, wingspan)
|
|||
if effect_factor > 0 then
|
||||
effect_factor = math.abs( half_wingspan - effect_factor )
|
||||
end
|
||||
|
||||
|
||||
local lift_factor = ((effect_factor) * 1) / (half_wingspan) --agora isso é um percentual
|
||||
local max_extra_lift_percent = 0.5 * lift --e aqui o maximo extra de sustentação
|
||||
local extra_lift = max_extra_lift_percent * lift_factor
|
||||
self._extra_lift = extra_lift
|
||||
end
|
||||
|
||||
|
||||
return self._extra_lift --return the value stored
|
||||
end
|
||||
|
||||
|
@ -271,7 +273,7 @@ function airutils.getLiftAccel(self, velocity, accel, longit_speed, roll, curr_p
|
|||
local accel_wind = vector.subtract(accel, wind) --why? because I need to fake more speed when against the wind to gain lift
|
||||
local vel_wind = vector.multiply(accel_wind, self.dtime)
|
||||
local new_velocity = vector.add(velocity, vel_wind)
|
||||
|
||||
|
||||
if longit_speed == nil then longit_speed = 0 end
|
||||
wingspan = wingspan or 10
|
||||
local ground_effect_extra_lift = airutils.get_ground_effect_lift(self, curr_pos, lift, wingspan)
|
||||
|
@ -283,7 +285,7 @@ function airutils.getLiftAccel(self, velocity, accel, longit_speed, roll, curr_p
|
|||
max_height = max_height or 20000
|
||||
local wing_config = 0
|
||||
if self._wing_configuration then wing_config = self._wing_configuration end --flaps!
|
||||
|
||||
|
||||
local retval = accel
|
||||
local min_speed = 1;
|
||||
if self._min_speed then min_speed = self._min_speed end
|
||||
|
@ -305,7 +307,7 @@ function airutils.getLiftAccel(self, velocity, accel, longit_speed, roll, curr_p
|
|||
|
||||
local rotation=self.object:get_rotation()
|
||||
local vrot = airutils.dir_to_rot(velocity,rotation)
|
||||
|
||||
|
||||
local hpitch,hyaw = pitchroll2pitchyaw(angle_of_attack,roll)
|
||||
|
||||
local hrot = {x=vrot.x+hpitch,y=vrot.y-hyaw,z=roll}
|
||||
|
@ -358,7 +360,7 @@ function airutils.elevator_auto_correction(self, longit_speed, dtime, max_speed,
|
|||
intensity = intensity or 500
|
||||
if longit_speed <= 0 then return end
|
||||
local factor = 1
|
||||
|
||||
|
||||
if self._elevator_angle > 0 then factor = -1 end
|
||||
local ref_speed = longit_speed
|
||||
if ref_speed > max_speed then ref_speed = max_speed end
|
||||
|
@ -366,7 +368,7 @@ function airutils.elevator_auto_correction(self, longit_speed, dtime, max_speed,
|
|||
local divisor = intensity
|
||||
speed_scale = speed_scale / divisor
|
||||
local correction = speed_scale * factor * (dtime/ideal_step)
|
||||
|
||||
|
||||
local before_correction = elevator_angle
|
||||
local new_elevator_angle = elevator_angle + correction
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
local storage = minetest.get_mod_storage()
|
||||
local storage = airutils.storage
|
||||
airutils.modname = minetest.get_current_modname()
|
||||
|
||||
--function to format formspec for mineclone. In case of minetest, just returns an empty string
|
||||
|
@ -19,54 +19,54 @@ local function get_formspec_by_size(self, size)
|
|||
end
|
||||
local default_inventory_formspecs = {
|
||||
["2"]="size[8,6]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;3.0,0;3,1;]" .. airutils.get_itemslot_bg(3.0, 0, 2, 1) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. airutils.get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"list[detached:" .. self._inv_id .. ";main;3.0,0;3,1;]" .. airutils.get_itemslot_bg(3.0, 0, 2, 1) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. airutils.get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"listring[]",
|
||||
|
||||
["3"]="size[8,6]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;2.5,0;3,1;]" .. airutils.get_itemslot_bg(2.5, 0, 3, 1) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. airutils.get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. airutils.get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"listring[]",
|
||||
|
||||
["4"]="size[8,6]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;2,0;4,1;]" .. airutils.get_itemslot_bg(2.0, 0, 4, 1) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. airutils.get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. airutils.get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"listring[]",
|
||||
|
||||
["6"]="size[8,6]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;1,0;6,1;]".. airutils.get_itemslot_bg(1.0, 0, 6, 1) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. airutils.get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. airutils.get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"listring[]",
|
||||
|
||||
["8"]="size[8,6]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;0,0;8,1;]".. airutils.get_itemslot_bg(0, 0, 8, 1) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. airutils.get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. airutils.get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"listring[]",
|
||||
|
||||
["12"]="size[8,7]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;1,0;6,2;]".. airutils.get_itemslot_bg(1, 0, 6, 2) ..
|
||||
"list[current_player;main;0,3;8,4;]" .. airutils.get_itemslot_bg(0, 3, 8, 4) ..
|
||||
"list[current_player;main;0,3;8,4;]" .. airutils.get_itemslot_bg(0, 3, 8, 4) ..
|
||||
"listring[]",
|
||||
|
||||
["16"]="size[8,7]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;0,0;8,2;]".. airutils.get_itemslot_bg(0, 0, 8, 2) ..
|
||||
"list[current_player;main;0,3;8,4;]" .. airutils.get_itemslot_bg(0, 3, 8, 4) ..
|
||||
"list[current_player;main;0,3;8,4;]" .. airutils.get_itemslot_bg(0, 3, 8, 4) ..
|
||||
"listring[]",
|
||||
|
||||
["24"]="size[8,8]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;0,0;8,3;]".. airutils.get_itemslot_bg(0, 0, 8, 3) ..
|
||||
"list[current_player;main;0,4;8,4;]" .. airutils.get_itemslot_bg(0, 4, 8, 4) ..
|
||||
"list[current_player;main;0,4;8,4;]" .. airutils.get_itemslot_bg(0, 4, 8, 4) ..
|
||||
"listring[]",
|
||||
|
||||
["32"]="size[8,9]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;0,0.3;8,4;]".. airutils.get_itemslot_bg(0, 0.3, 8, 4) ..
|
||||
"list[current_player;main;0,5;8,4;]".. airutils.get_itemslot_bg(0, 5, 8, 4) ..
|
||||
"list[current_player;main;0,5;8,4;]".. airutils.get_itemslot_bg(0, 5, 8, 4) ..
|
||||
"listring[]" ..
|
||||
hotbar,
|
||||
|
||||
["50"]="size[10,10]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;0,0;10,5;]".. airutils.get_itemslot_bg(0, 0, 10, 5) ..
|
||||
"list[current_player;main;1,6;8,4;]" .. airutils.get_itemslot_bg(1, 6, 8, 4) ..
|
||||
"list[current_player;main;1,6;8,4;]" .. airutils.get_itemslot_bg(1, 6, 8, 4) ..
|
||||
"listring[]",
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ function airutils.remove_inventory(self)
|
|||
local pos = self.object:get_pos()
|
||||
for k, v in pairs(inv_content) do
|
||||
local count = 0
|
||||
for i = 0,v:get_count()-1,1
|
||||
for i = 0,v:get_count()-1,1
|
||||
do
|
||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},v:get_name())
|
||||
count = count + 1
|
||||
|
@ -196,7 +196,7 @@ function airutils.list_inventory(self)
|
|||
local inventory = airutils.get_inventory(self)
|
||||
if inventory then
|
||||
local list = inventory.get_list("main")
|
||||
|
||||
|
||||
minetest.chat_send_all(dump(list))
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue