mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-16 16:11:06 +01:00
[mcl_fishing] fix warnings
This commit is contained in:
parent
82396bd994
commit
a1acf6d3c1
1 changed files with 133 additions and 148 deletions
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
local S = minetest.get_translator("mcl_fishing")
|
local S = minetest.get_translator("mcl_fishing")
|
||||||
|
|
||||||
|
local math = math
|
||||||
|
|
||||||
local bobber_ENTITY={
|
local bobber_ENTITY={
|
||||||
physical = false,
|
physical = false,
|
||||||
timer=0,
|
timer=0,
|
||||||
|
@ -34,9 +36,8 @@ local fish = function(itemstack, player, pointed_thing)
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
|
|
||||||
local objs = minetest.get_objects_inside_radius(pos, 125)
|
local objs = minetest.get_objects_inside_radius(pos, 125)
|
||||||
local num = 0
|
local ent
|
||||||
local ent = nil
|
local noent = false
|
||||||
local noent = true
|
|
||||||
|
|
||||||
local durability = 65
|
local durability = 65
|
||||||
local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
|
local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
|
||||||
|
@ -50,11 +51,8 @@ local fish = function(itemstack, player, pointed_thing)
|
||||||
if ent then
|
if ent then
|
||||||
if ent.player and ent.objtype=="fishing" then
|
if ent.player and ent.objtype=="fishing" then
|
||||||
if (player:get_player_name() == ent.player) then
|
if (player:get_player_name() == ent.player) then
|
||||||
noent = false
|
|
||||||
if ent._dive == true then
|
if ent._dive == true then
|
||||||
local itemname
|
|
||||||
local items
|
local items
|
||||||
local itemcount = 1
|
|
||||||
local pr = PseudoRandom(os.time() * math.random(1, 100))
|
local pr = PseudoRandom(os.time() * math.random(1, 100))
|
||||||
local r = pr:next(1, 100)
|
local r = pr:next(1, 100)
|
||||||
local fish_values = {85, 84.8, 84.7, 84.5}
|
local fish_values = {85, 84.8, 84.7, 84.5}
|
||||||
|
@ -145,7 +143,8 @@ local fish = function(itemstack, player, pointed_thing)
|
||||||
end
|
end
|
||||||
--Destroy bobber.
|
--Destroy bobber.
|
||||||
ent.object:remove()
|
ent.object:remove()
|
||||||
return itemstack
|
noent = false
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -163,11 +162,12 @@ local fish = function(itemstack, player, pointed_thing)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--If no bobber or flying_bobber exists then throw bobber.
|
--If no bobber or flying_bobber exists then throw bobber.
|
||||||
if noent == true then
|
if noent then
|
||||||
local playerpos = player:get_pos()
|
local playerpos = player:get_pos()
|
||||||
local dir = player:get_look_dir()
|
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())
|
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
|
end
|
||||||
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Movement function of bobber
|
-- 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)
|
mcl_throwing.register_throwable_object("mcl_fishing:flying_bobber", "mcl_fishing:flying_bobber_entity", 5)
|
||||||
|
|
||||||
-- If player leaves area, remove bobber.
|
local function remove_bobber(player)
|
||||||
minetest.register_on_leaveplayer(function(player)
|
|
||||||
local objs = minetest.get_objects_inside_radius(player:get_pos(), 250)
|
local objs = minetest.get_objects_inside_radius(player:get_pos(), 250)
|
||||||
local ent = nil
|
|
||||||
local noent = true
|
|
||||||
for n = 1, #objs do
|
for n = 1, #objs do
|
||||||
ent = objs[n]:get_luaentity()
|
local ent = objs[n]:get_luaentity()
|
||||||
if ent then
|
if ent then
|
||||||
if ent.player and ent.objtype=="fishing" then
|
if ent.player and ent.objtype=="fishing" then
|
||||||
ent.object:remove()
|
ent.object:remove()
|
||||||
|
@ -349,26 +347,13 @@ minetest.register_on_leaveplayer(function(player)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end
|
||||||
|
|
||||||
|
-- If player leaves area, remove bobber.
|
||||||
|
minetest.register_on_leaveplayer(remove_bobber)
|
||||||
|
|
||||||
-- If player dies, remove bobber.
|
-- If player dies, remove bobber.
|
||||||
minetest.register_on_dieplayer(function(player)
|
minetest.register_on_dieplayer(remove_bobber)
|
||||||
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)
|
|
||||||
|
|
||||||
-- Fishing Rod
|
-- Fishing Rod
|
||||||
minetest.register_tool("mcl_fishing:fishing_rod", {
|
minetest.register_tool("mcl_fishing:fishing_rod", {
|
||||||
|
|
Loading…
Reference in a new issue