mirror of
https://github.com/MinetestForFun/fishing.git
synced 2024-11-13 01:20:19 +01:00
Merge pull request #4 from Panquesito7/master
Replace deprecated functions with newer ones
This commit is contained in:
commit
f81a90c20a
22
bobber.lua
22
bobber.lua
|
@ -64,7 +64,7 @@ local FISHING_BOBBER_ENTITY={
|
|||
end
|
||||
end
|
||||
-- make sound and remove bobber
|
||||
minetest.sound_play("fishing_bobber1", { pos = self.object:getpos(), gain = 0.5, })
|
||||
minetest.sound_play("fishing_bobber1", { pos = self.object:get_pos(), gain = 0.5, })
|
||||
self.object:remove()
|
||||
end,
|
||||
|
||||
|
@ -78,7 +78,7 @@ local FISHING_BOBBER_ENTITY={
|
|||
return
|
||||
end
|
||||
local inv = clicker:get_inventory()
|
||||
local pos = self.object:getpos()
|
||||
local pos = self.object:get_pos()
|
||||
local item_name = item:get_name()
|
||||
|
||||
if string.find(item_name, "fishing:pole_") ~= nil then
|
||||
|
@ -110,7 +110,7 @@ local FISHING_BOBBER_ENTITY={
|
|||
end
|
||||
end
|
||||
-- weither player has fishing pole or not
|
||||
minetest.sound_play("fishing_bobber1", { pos = self.object:getpos(), gain = 0.5, })
|
||||
minetest.sound_play("fishing_bobber1", { pos = self.object:get_pos(), gain = 0.5, })
|
||||
self.object:remove()
|
||||
|
||||
elseif item_name == "fishing:baitball" then
|
||||
|
@ -127,14 +127,14 @@ local FISHING_BOBBER_ENTITY={
|
|||
0.25, 0.5, -- min size, max size
|
||||
false, "fishing_particle_baitball.png")
|
||||
-- add sound
|
||||
minetest.sound_play("fishing_baitball", {pos = self.object:getpos(), gain = 0.2, })
|
||||
minetest.sound_play("fishing_baitball", {pos = self.object:get_pos(), gain = 0.2, })
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
-- AS SOON AS THE BOBBER IS PLACED IT WILL ACT LIKE
|
||||
on_step = function(self, dtime)
|
||||
local pos = self.object:getpos()
|
||||
local pos = self.object:get_pos()
|
||||
--remove if no owner, no player, owner no in bobber_view_range
|
||||
if self.owner == nil then self.object:remove(); return end
|
||||
--remove if not node water
|
||||
|
@ -148,7 +148,7 @@ local FISHING_BOBBER_ENTITY={
|
|||
end
|
||||
local player = minetest.get_player_by_name(self.owner)
|
||||
if not player then self.object:remove(); return end
|
||||
local p = player:getpos()
|
||||
local p = player:get_pos()
|
||||
local dist = ((p.x-pos.x)^2 + (p.y-pos.y)^2 + (p.z-pos.z)^2)^0.5
|
||||
if dist > fishing_setting.settings["bobber_view_range"] then
|
||||
minetest.sound_play("fishing_bobber1", {pos = self.object:getpos(),gain = 0.5,})
|
||||
|
@ -158,7 +158,7 @@ local FISHING_BOBBER_ENTITY={
|
|||
|
||||
--rotate bobber
|
||||
if math.random(1, 4) == 1 then
|
||||
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/2880*math.pi))
|
||||
self.object:set_yaw(self.object:getyaw()+((math.random(0,360)-180)/2880*math.pi))
|
||||
end
|
||||
|
||||
self.timer = self.timer + 1
|
||||
|
@ -167,11 +167,11 @@ local FISHING_BOBBER_ENTITY={
|
|||
if self.prize ~= "" and math.random(1,3) == 1 then
|
||||
if self.old_pos2 == true then
|
||||
pos.y = pos.y-0.0280
|
||||
self.object:moveto(pos, false)
|
||||
self.object:move_to(pos, false)
|
||||
self.old_pos2 = false
|
||||
else
|
||||
pos.y = pos.y+0.0280
|
||||
self.object:moveto(pos, false)
|
||||
self.object:move_to(pos, false)
|
||||
self.old_pos2 = true
|
||||
end
|
||||
end
|
||||
|
@ -184,7 +184,7 @@ local FISHING_BOBBER_ENTITY={
|
|||
minetest.add_entity({x=pos.x, y=pos.y-1, z=pos.z}, self.prize[1]..":"..self.prize[2])
|
||||
end
|
||||
self.prize = ""
|
||||
self.object:moveto(self.old_pos, false)
|
||||
self.object:move_to(self.old_pos, false)
|
||||
--Once the fish are not hungry :), baitball increase hungry + 20%
|
||||
if math.random(1, 100) > fishing_setting.baits[self.bait]["hungry"] + self.baitball then
|
||||
--Fish not hungry !(
|
||||
|
@ -221,7 +221,7 @@ local FISHING_BOBBER_ENTITY={
|
|||
|
||||
if self.prize ~= "" then
|
||||
pos.y = self.old_pos.y-0.1
|
||||
self.object:moveto(pos, false)
|
||||
self.object:move_to(pos, false)
|
||||
minetest.sound_play("fishing_bobber1", {pos=pos,gain = 0.5,})
|
||||
end
|
||||
end,
|
||||
|
|
|
@ -62,7 +62,7 @@ local FISHING_BOBBER_SHARK_ENTITY={
|
|||
end
|
||||
end
|
||||
-- make sound and remove bobber
|
||||
minetest.sound_play("fishing_bobber1", { pos = self.object:getpos(), gain = 0.5, })
|
||||
minetest.sound_play("fishing_bobber1", { pos = self.object:get_pos(), gain = 0.5, })
|
||||
self.object:remove()
|
||||
end,
|
||||
|
||||
|
@ -76,7 +76,7 @@ local FISHING_BOBBER_SHARK_ENTITY={
|
|||
return
|
||||
end
|
||||
local inv = clicker:get_inventory()
|
||||
local pos = self.object:getpos()
|
||||
local pos = self.object:get_pos()
|
||||
local item_name = item:get_name()
|
||||
|
||||
if string.find(item_name, "fishing:pole_") ~= nil then
|
||||
|
@ -97,7 +97,7 @@ local FISHING_BOBBER_SHARK_ENTITY={
|
|||
if inv:room_for_item("main", {name=name, count=1, wear=wear_value, metadata=""}) then
|
||||
inv:add_item("main", {name=name, count=1, wear=wear_value, metadata=""})
|
||||
else
|
||||
minetest.spawn_item(clicker:getpos(), {name=name, count=1, wear=wear_value, metadata=""})
|
||||
minetest.spawn_item(clicker:get_pos(), {name=name, count=1, wear=wear_value, metadata=""})
|
||||
end
|
||||
end
|
||||
else
|
||||
|
@ -108,7 +108,7 @@ local FISHING_BOBBER_SHARK_ENTITY={
|
|||
end
|
||||
end
|
||||
-- weither player has fishing pole or not
|
||||
minetest.sound_play("fishing_bobber1", { pos = self.object:getpos(), gain = 0.5, })
|
||||
minetest.sound_play("fishing_bobber1", { pos = self.object:get_pos(), gain = 0.5, })
|
||||
self.object:remove()
|
||||
|
||||
elseif item_name == "fishing:baitball_shark" then
|
||||
|
@ -132,7 +132,7 @@ local FISHING_BOBBER_SHARK_ENTITY={
|
|||
|
||||
-- AS SOON AS THE BOBBER IS PLACED IT WILL ACT LIKE
|
||||
on_step = function(self, dtime)
|
||||
local pos = self.object:getpos()
|
||||
local pos = self.object:get_pos()
|
||||
--remove if no owner, no player, owner no in bobber_view_range
|
||||
if self.owner == nil then self.object:remove(); return end
|
||||
--remove if not node water
|
||||
|
@ -146,17 +146,17 @@ local FISHING_BOBBER_SHARK_ENTITY={
|
|||
end
|
||||
local player = minetest.get_player_by_name(self.owner)
|
||||
if not player then self.object:remove(); return end
|
||||
local p = player:getpos()
|
||||
local p = player:get_pos()
|
||||
local dist = ((p.x-pos.x)^2 + (p.y-pos.y)^2 + (p.z-pos.z)^2)^0.5
|
||||
if dist > fishing_setting.settings["bobber_view_range"] then
|
||||
minetest.sound_play("fishing_bobber1", {pos = self.object:getpos(),gain = 0.5,})
|
||||
minetest.sound_play("fishing_bobber1", {pos = self.object:get_pos(),gain = 0.5,})
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
||||
--rotate bobber
|
||||
if math.random(1, 4) == 1 then
|
||||
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/2880*math.pi))
|
||||
self.object:setyaw(self.object:get_yaw()+((math.random(0,360)-180)/2880*math.pi))
|
||||
end
|
||||
|
||||
self.timer = self.timer + 1
|
||||
|
@ -165,11 +165,11 @@ local FISHING_BOBBER_SHARK_ENTITY={
|
|||
if self.prize ~= "" and math.random(1,3) == 1 then
|
||||
if self.old_pos2 == true then
|
||||
pos.y = pos.y-0.050
|
||||
self.object:moveto(pos, false)
|
||||
self.object:move_to(pos, false)
|
||||
self.old_pos2 = false
|
||||
else
|
||||
pos.y = pos.y+0.050
|
||||
self.object:moveto(pos, false)
|
||||
self.object:move_to(pos, false)
|
||||
self.old_pos2 = true
|
||||
end
|
||||
end
|
||||
|
@ -182,7 +182,7 @@ local FISHING_BOBBER_SHARK_ENTITY={
|
|||
minetest.add_entity({x=pos.x, y=pos.y-1, z=pos.z}, self.prize[1]..":"..self.prize[2])
|
||||
end
|
||||
self.prize = ""
|
||||
self.object:moveto(self.old_pos, false)
|
||||
self.object:move_to(self.old_pos, false)
|
||||
--Once the fish are not hungry :), baitball increase hungry + 20%
|
||||
if math.random(1, 100) > fishing_setting.baits[self.bait]["hungry"] + self.baitball then
|
||||
--Fish not hungry !(
|
||||
|
@ -225,7 +225,7 @@ local FISHING_BOBBER_SHARK_ENTITY={
|
|||
|
||||
if self.prize ~= "" then
|
||||
pos.y = self.old_pos.y-0.140
|
||||
self.object:moveto(pos, false)
|
||||
self.object:move_to(pos, false)
|
||||
minetest.sound_play("fishing_bobber1", {pos=pos,gain = 0.5,})
|
||||
end
|
||||
end,
|
||||
|
|
|
@ -370,7 +370,7 @@ function fishing_setting.func.add_to_trophies(player, fish, desc)
|
|||
if inv:room_for_item("main", {name=name, count=1, wear=0, metadata=""}) then
|
||||
inv:add_item("main", {name=name, count=1, wear=0, metadata=""})
|
||||
else
|
||||
minetest.spawn_item(player:getpos(), {name=name, count=1, wear=0, metadata=""})
|
||||
minetest.spawn_item(player:get_pos(), {name=name, count=1, wear=0, metadata=""})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -487,10 +487,9 @@ function fishing_setting.func.load_planned()
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
fishing_setting.func.load_planned()
|
||||
|
||||
|
||||
|
||||
function fishing_setting.func.save_planned()
|
||||
local input = io.open(fishing_setting.file_planned, "w")
|
||||
if input then
|
||||
|
@ -824,4 +823,3 @@ function fishing_setting.func.tick()
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
3
mod.conf
Normal file
3
mod.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
name = fishing
|
||||
depends = default, farming
|
||||
optional_depends = unified_inventory, moreblocks, ropes, moreores, mobs, flowers_plus, seaplants, mobs_fish, mobs_shark
|
26
worms.lua
26
worms.lua
|
@ -57,11 +57,11 @@ minetest.register_entity("fishing:bait_worm_entity", {
|
|||
end,
|
||||
-- AI :D
|
||||
on_step = function(self, dtime)
|
||||
local pos = self.object:getpos()
|
||||
local pos = self.object:get_pos()
|
||||
-- despawn when no player in range
|
||||
local remove_entity = true
|
||||
for _,player in pairs(minetest.get_connected_players()) do
|
||||
local p = player:getpos()
|
||||
local p = player:get_pos()
|
||||
local dist = ((p.x-pos.x)^2 + (p.y-pos.y)^2 + (p.z-pos.z)^2)^0.5
|
||||
if dist < 25 then
|
||||
remove_entity = false
|
||||
|
@ -77,24 +77,24 @@ minetest.register_entity("fishing:bait_worm_entity", {
|
|||
local look_whats_up = function(self)
|
||||
self.object:set_hp(self.object:get_hp()-self.damage_over_time) -- creature is getting older
|
||||
if n.name == "air" then -- fall when in air
|
||||
self.object:moveto({x=pos.x,y=pos.y-0.5,z=pos.z})
|
||||
self.object:move_to({x=pos.x,y=pos.y-0.5,z=pos.z})
|
||||
self.object:set_hp(self.object:get_hp()-75)
|
||||
|
||||
--if n.name == "snappy" then -- fall when leaves or similar
|
||||
elseif minetest.get_item_group(n.name, "snappy") ~= 0 then
|
||||
self.object:moveto({x=pos.x+(0.001*(math.random(-32, 32))),y=pos.y-(0.001*(math.random(0, 64))),z=pos.z+(0.001*(math.random(-32, 32)))})
|
||||
self.object:move_to({x=pos.x+(0.001*(math.random(-32, 32))),y=pos.y-(0.001*(math.random(0, 64))),z=pos.z+(0.001*(math.random(-32, 32)))})
|
||||
|
||||
elseif string.find(n.name, "default:water") then -- sink when in water
|
||||
self.object:moveto({x=pos.x,y=pos.y-0.25,z=pos.z})
|
||||
self.object:move_to({x=pos.x,y=pos.y-0.25,z=pos.z})
|
||||
self.object:set_hp(self.object:get_hp()-37)
|
||||
|
||||
elseif minetest.get_item_group(n.name, "soil") ~= 0 then
|
||||
if minetest.get_item_group(minetest.get_node({x=pos.x,y=pos.y-0.1,z=pos.z}).name, "soil") == 0 and self.object:get_hp() > 200 then
|
||||
self.object:set_hp(199)
|
||||
elseif self.object:get_hp() > 200 then -- leave dirt to see whats going on
|
||||
self.object:moveto({x=pos.x+(0.001*(math.random(-2, 2))),y=pos.y+0.003,z=pos.z+(0.001*(math.random(-2, 2)))})
|
||||
self.object:move_to({x=pos.x+(0.001*(math.random(-2, 2))),y=pos.y+0.003,z=pos.z+(0.001*(math.random(-2, 2)))})
|
||||
elseif self.object:get_hp() < 199 then -- no rain here, let's get outa here
|
||||
self.object:moveto({x=pos.x+(0.001*(math.random(-2, 2))),y=pos.y-0.001,z=pos.z+(0.001*(math.random(-2, 2)))})
|
||||
self.object:move_to({x=pos.x+(0.001*(math.random(-2, 2))),y=pos.y-0.001,z=pos.z+(0.001*(math.random(-2, 2)))})
|
||||
elseif self.object:get_hp() == 0 then
|
||||
self.object:remove()
|
||||
end
|
||||
|
@ -111,15 +111,15 @@ minetest.register_entity("fishing:bait_worm_entity", {
|
|||
local goal_4a = check_group(minetest.get_node({x = pos.x, y = pos.y+0.6, z = pos.z - 1}).name, "soil")
|
||||
-- if there's dirt nearby, go there
|
||||
if goal_01 ~= 0 or goal_1a ~= 0 then
|
||||
self.object:moveto({x=pos.x+0.002,y=pos.y,z=pos.z+(0.001*(math.random(-2, 2)))})
|
||||
self.object:move_to({x=pos.x+0.002,y=pos.y,z=pos.z+(0.001*(math.random(-2, 2)))})
|
||||
elseif goal_02 ~= 0 or goal_2a ~= 0 then
|
||||
self.object:moveto({x=pos.x+(0.001*(math.random(-2, 2))),y=pos.y,z=pos.z+0.002})
|
||||
self.object:move_to({x=pos.x+(0.001*(math.random(-2, 2))),y=pos.y,z=pos.z+0.002})
|
||||
elseif goal_03 ~= 0 or goal_3a ~= 0 then
|
||||
self.object:moveto({x=pos.x-0.002,y=pos.y,z=pos.z+(0.001*(math.random(-2, 2)))})
|
||||
self.object:move_to({x=pos.x-0.002,y=pos.y,z=pos.z+(0.001*(math.random(-2, 2)))})
|
||||
elseif goal_04 ~= 0 or goal_4a ~= 0 then
|
||||
self.object:moveto({x=pos.x+(0.001*(math.random(-2, 2))),y=pos.y,z=pos.z-0.002})
|
||||
self.object:move_to({x=pos.x+(0.001*(math.random(-2, 2))),y=pos.y,z=pos.z-0.002})
|
||||
else -- I'm lost, no dirt
|
||||
self.object:moveto({x=pos.x+(0.001*(math.random(-8, 8))),y=pos.y,z=pos.z+(0.001*(math.random(-8, 8)))})
|
||||
self.object:move_to({x=pos.x+(0.001*(math.random(-8, 8))),y=pos.y,z=pos.z+(0.001*(math.random(-8, 8)))})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -219,7 +219,7 @@ else
|
|||
itemstack:add_wear(65535/(uses-1))
|
||||
if itemstack:get_wear() == 0 and minetest.get_modpath("invtweak") then
|
||||
local index = user:get_wield_index()
|
||||
minetest.sound_play("invtweak_tool_break", {pos = user:getpos(), gain = 0.9, max_hear_distance = 5})
|
||||
minetest.sound_play("invtweak_tool_break", {pos = user:get_pos(), gain = 0.9, max_hear_distance = 5})
|
||||
minetest.after(0.20, refill, user, tool_name, index)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user