[mcl_bows] fix warnings

This commit is contained in:
AFCMS 2021-05-23 01:06:34 +02:00
parent fdfb586b16
commit b7bf566190
2 changed files with 19 additions and 17 deletions

@ -1,29 +1,32 @@
local S = minetest.get_translator("mcl_bows")
local math = math
local vector = vector
-- Time in seconds after which a stuck arrow is deleted
local ARROW_TIMEOUT = 60
-- Time after which stuck arrow is rechecked for being stuck
local STUCK_RECHECK_TIME = 5
local GRAVITY = 9.81
--local GRAVITY = 9.81
local YAW_OFFSET = -math.pi/2
local dir_to_pitch = function(dir)
local dir2 = vector.normalize(dir)
local function dir_to_pitch(dir)
--local dir2 = vector.normalize(dir)
local xz = math.abs(dir.x) + math.abs(dir.z)
return -math.atan2(-dir.y, xz)
end
local random_arrow_positions = function(positions, placement)
if positions == 'x' then
local function random_arrow_positions(positions, placement)
if positions == "x" then
return math.random(-4, 4)
elseif positions == 'y' then
elseif positions == "y" then
return math.random(0, 10)
end
if placement == 'front' and positions == 'z' then
if placement == "front" and positions == "z" then
return 3
elseif placement == 'back' and positions == 'z' then
elseif placement == "back" and positions == "z" then
return -3
end
return 0
@ -257,12 +260,12 @@ ARROW_ENTITY.on_step = function(self, dtime)
damage_groups={fleshy=self._damage},
}, self.object:get_velocity())
if obj:is_player() then
local placement = ''
local placement
self._placement = math.random(1, 2)
if self._placement == 1 then
placement = 'front'
placement = "front"
else
placement = 'back'
placement = "back"
end
self._in_player = true
if self._placement == 2 then
@ -393,7 +396,7 @@ ARROW_ENTITY.on_step = function(self, dtime)
if not v then
v = 0
end
local old_v = self._viscosity
--local old_v = self._viscosity
self._viscosity = v
local vpenalty = math.max(0.1, 0.98 - 0.1 * v)
if math.abs(vel.x) > 0.001 then

@ -228,11 +228,10 @@ end
controls.register_on_release(function(player, key, time)
if key~="RMB" then return end
local inv = minetest.get_inventory({type="player", name=player:get_player_name()})
--local inv = minetest.get_inventory({type="player", name=player:get_player_name()})
local wielditem = player:get_wielded_item()
if (wielditem:get_name()=="mcl_bows:bow_0" or wielditem:get_name()=="mcl_bows:bow_1" or wielditem:get_name()=="mcl_bows:bow_2" or
wielditem:get_name()=="mcl_bows:bow_0_enchanted" or wielditem:get_name()=="mcl_bows:bow_1_enchanted" or wielditem:get_name()=="mcl_bows:bow_2_enchanted") then
local has_shot = false
local enchanted = mcl_enchanting.is_enchanted(wielditem:get_name())
local speed, damage
@ -272,7 +271,7 @@ controls.register_on_release(function(player, key, time)
damage = math.max(1, math.floor(9 * charge_ratio))
end
has_shot = player_shoot_arrow(wielditem, player, speed, damage, is_critical)
local has_shot = player_shoot_arrow(wielditem, player, speed, damage, is_critical)
if enchanted then
wielditem:set_name("mcl_bows:bow_enchanted")
@ -299,7 +298,7 @@ controls.register_on_hold(function(player, key, time)
if key ~= "RMB" or not (creative or get_arrow(player)) then
return
end
local inv = minetest.get_inventory({type="player", name=name})
--local inv = minetest.get_inventory({type="player", name=name})
local wielditem = player:get_wielded_item()
if bow_load[name] == nil and (wielditem:get_name()=="mcl_bows:bow" or wielditem:get_name()=="mcl_bows:bow_enchanted") and wielditem:get_meta():get("active") and (creative or get_arrow(player)) then
local enchanted = mcl_enchanting.is_enchanted(wielditem:get_name())
@ -346,7 +345,7 @@ minetest.register_globalstep(function(dtime)
local name = player:get_player_name()
local wielditem = player:get_wielded_item()
local wieldindex = player:get_wield_index()
local controls = player:get_player_control()
--local controls = player:get_player_control()
if type(bow_load[name]) == "number" and ((wielditem:get_name()~="mcl_bows:bow_0" and wielditem:get_name()~="mcl_bows:bow_1" and wielditem:get_name()~="mcl_bows:bow_2" and wielditem:get_name()~="mcl_bows:bow_0_enchanted" and wielditem:get_name()~="mcl_bows:bow_1_enchanted" and wielditem:get_name()~="mcl_bows:bow_2_enchanted") or wieldindex ~= bow_index[name]) then
reset_bow_state(player, true)
end