forked from MineClone5/MineClone5
[mcl_fishing] fix warnings
This commit is contained in:
parent
82396bd994
commit
a1acf6d3c1
|
@ -2,6 +2,8 @@
|
|||
|
||||
local S = minetest.get_translator("mcl_fishing")
|
||||
|
||||
local math = math
|
||||
|
||||
local bobber_ENTITY={
|
||||
physical = false,
|
||||
timer=0,
|
||||
|
@ -34,9 +36,8 @@ local fish = function(itemstack, player, pointed_thing)
|
|||
local pos = player:get_pos()
|
||||
|
||||
local objs = minetest.get_objects_inside_radius(pos, 125)
|
||||
local num = 0
|
||||
local ent = nil
|
||||
local noent = true
|
||||
local ent
|
||||
local noent = false
|
||||
|
||||
local durability = 65
|
||||
local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
|
||||
|
@ -50,11 +51,8 @@ local fish = function(itemstack, player, pointed_thing)
|
|||
if ent then
|
||||
if ent.player and ent.objtype=="fishing" then
|
||||
if (player:get_player_name() == ent.player) then
|
||||
noent = false
|
||||
if ent._dive == true then
|
||||
local itemname
|
||||
local items
|
||||
local itemcount = 1
|
||||
local pr = PseudoRandom(os.time() * math.random(1, 100))
|
||||
local r = pr:next(1, 100)
|
||||
local fish_values = {85, 84.8, 84.7, 84.5}
|
||||
|
@ -145,7 +143,8 @@ local fish = function(itemstack, player, pointed_thing)
|
|||
end
|
||||
--Destroy bobber.
|
||||
ent.object:remove()
|
||||
return itemstack
|
||||
noent = false
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -163,11 +162,12 @@ local fish = function(itemstack, player, pointed_thing)
|
|||
end
|
||||
end
|
||||
--If no bobber or flying_bobber exists then throw bobber.
|
||||
if noent == true then
|
||||
if noent then
|
||||
local playerpos = player:get_pos()
|
||||
local dir = player:get_look_dir()
|
||||
mcl_throwing.throw("mcl_fishing:flying_bobber", {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, 15, player:get_player_name())
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- Movement function of bobber
|
||||
|
@ -334,13 +334,11 @@ minetest.register_entity("mcl_fishing:flying_bobber_entity", flying_bobber_ENTIT
|
|||
|
||||
mcl_throwing.register_throwable_object("mcl_fishing:flying_bobber", "mcl_fishing:flying_bobber_entity", 5)
|
||||
|
||||
-- If player leaves area, remove bobber.
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local function remove_bobber(player)
|
||||
local objs = minetest.get_objects_inside_radius(player:get_pos(), 250)
|
||||
local ent = nil
|
||||
local noent = true
|
||||
|
||||
for n = 1, #objs do
|
||||
ent = objs[n]:get_luaentity()
|
||||
local ent = objs[n]:get_luaentity()
|
||||
if ent then
|
||||
if ent.player and ent.objtype=="fishing" then
|
||||
ent.object:remove()
|
||||
|
@ -349,26 +347,13 @@ minetest.register_on_leaveplayer(function(player)
|
|||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- If player leaves area, remove bobber.
|
||||
minetest.register_on_leaveplayer(remove_bobber)
|
||||
|
||||
-- If player dies, remove bobber.
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
local objs = minetest.get_objects_inside_radius(player:get_pos(), 250)
|
||||
local num = 0
|
||||
local ent = nil
|
||||
local noent = true
|
||||
|
||||
for n = 1, #objs do
|
||||
ent = objs[n]:get_luaentity()
|
||||
if ent then
|
||||
if ent.player and ent.objtype=="fishing" then
|
||||
ent.object:remove()
|
||||
elseif ent._thrower and ent.objtype=="fishing" then
|
||||
ent.object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
minetest.register_on_dieplayer(remove_bobber)
|
||||
|
||||
-- Fishing Rod
|
||||
minetest.register_tool("mcl_fishing:fishing_rod", {
|
||||
|
|
Loading…
Reference in New Issue