forked from MineClone5/MineClone5
[mcl_bows] fix warnings
This commit is contained in:
parent
fdfb586b16
commit
b7bf566190
|
@ -1,29 +1,32 @@
|
||||||
local S = minetest.get_translator("mcl_bows")
|
local S = minetest.get_translator("mcl_bows")
|
||||||
|
|
||||||
|
local math = math
|
||||||
|
local vector = vector
|
||||||
|
|
||||||
-- Time in seconds after which a stuck arrow is deleted
|
-- Time in seconds after which a stuck arrow is deleted
|
||||||
local ARROW_TIMEOUT = 60
|
local ARROW_TIMEOUT = 60
|
||||||
-- Time after which stuck arrow is rechecked for being stuck
|
-- Time after which stuck arrow is rechecked for being stuck
|
||||||
local STUCK_RECHECK_TIME = 5
|
local STUCK_RECHECK_TIME = 5
|
||||||
|
|
||||||
local GRAVITY = 9.81
|
--local GRAVITY = 9.81
|
||||||
|
|
||||||
local YAW_OFFSET = -math.pi/2
|
local YAW_OFFSET = -math.pi/2
|
||||||
|
|
||||||
local dir_to_pitch = function(dir)
|
local function dir_to_pitch(dir)
|
||||||
local dir2 = vector.normalize(dir)
|
--local dir2 = vector.normalize(dir)
|
||||||
local xz = math.abs(dir.x) + math.abs(dir.z)
|
local xz = math.abs(dir.x) + math.abs(dir.z)
|
||||||
return -math.atan2(-dir.y, xz)
|
return -math.atan2(-dir.y, xz)
|
||||||
end
|
end
|
||||||
|
|
||||||
local random_arrow_positions = function(positions, placement)
|
local function random_arrow_positions(positions, placement)
|
||||||
if positions == 'x' then
|
if positions == "x" then
|
||||||
return math.random(-4, 4)
|
return math.random(-4, 4)
|
||||||
elseif positions == 'y' then
|
elseif positions == "y" then
|
||||||
return math.random(0, 10)
|
return math.random(0, 10)
|
||||||
end
|
end
|
||||||
if placement == 'front' and positions == 'z' then
|
if placement == "front" and positions == "z" then
|
||||||
return 3
|
return 3
|
||||||
elseif placement == 'back' and positions == 'z' then
|
elseif placement == "back" and positions == "z" then
|
||||||
return -3
|
return -3
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
|
@ -257,12 +260,12 @@ ARROW_ENTITY.on_step = function(self, dtime)
|
||||||
damage_groups={fleshy=self._damage},
|
damage_groups={fleshy=self._damage},
|
||||||
}, self.object:get_velocity())
|
}, self.object:get_velocity())
|
||||||
if obj:is_player() then
|
if obj:is_player() then
|
||||||
local placement = ''
|
local placement
|
||||||
self._placement = math.random(1, 2)
|
self._placement = math.random(1, 2)
|
||||||
if self._placement == 1 then
|
if self._placement == 1 then
|
||||||
placement = 'front'
|
placement = "front"
|
||||||
else
|
else
|
||||||
placement = 'back'
|
placement = "back"
|
||||||
end
|
end
|
||||||
self._in_player = true
|
self._in_player = true
|
||||||
if self._placement == 2 then
|
if self._placement == 2 then
|
||||||
|
@ -393,7 +396,7 @@ ARROW_ENTITY.on_step = function(self, dtime)
|
||||||
if not v then
|
if not v then
|
||||||
v = 0
|
v = 0
|
||||||
end
|
end
|
||||||
local old_v = self._viscosity
|
--local old_v = self._viscosity
|
||||||
self._viscosity = v
|
self._viscosity = v
|
||||||
local vpenalty = math.max(0.1, 0.98 - 0.1 * v)
|
local vpenalty = math.max(0.1, 0.98 - 0.1 * v)
|
||||||
if math.abs(vel.x) > 0.001 then
|
if math.abs(vel.x) > 0.001 then
|
||||||
|
|
|
@ -228,11 +228,10 @@ end
|
||||||
|
|
||||||
controls.register_on_release(function(player, key, time)
|
controls.register_on_release(function(player, key, time)
|
||||||
if key~="RMB" then return end
|
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()
|
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
|
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
|
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 enchanted = mcl_enchanting.is_enchanted(wielditem:get_name())
|
||||||
local speed, damage
|
local speed, damage
|
||||||
|
@ -272,7 +271,7 @@ controls.register_on_release(function(player, key, time)
|
||||||
damage = math.max(1, math.floor(9 * charge_ratio))
|
damage = math.max(1, math.floor(9 * charge_ratio))
|
||||||
end
|
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
|
if enchanted then
|
||||||
wielditem:set_name("mcl_bows:bow_enchanted")
|
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
|
if key ~= "RMB" or not (creative or get_arrow(player)) then
|
||||||
return
|
return
|
||||||
end
|
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()
|
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
|
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())
|
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 name = player:get_player_name()
|
||||||
local wielditem = player:get_wielded_item()
|
local wielditem = player:get_wielded_item()
|
||||||
local wieldindex = player:get_wield_index()
|
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
|
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)
|
reset_bow_state(player, true)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue