1
0
mirror of https://github.com/MinetestForFun/fishing.git synced 2025-01-09 10:30:16 +01:00

Update bobber.lua

This commit is contained in:
Panquesito7 2019-08-22 19:30:52 -05:00 committed by GitHub
parent 091611b1cd
commit ae9b315884
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,7 +64,7 @@ local FISHING_BOBBER_ENTITY={
end end
end end
-- make sound and remove bobber -- 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() self.object:remove()
end, end,
@ -78,7 +78,7 @@ local FISHING_BOBBER_ENTITY={
return return
end end
local inv = clicker:get_inventory() local inv = clicker:get_inventory()
local pos = self.object:getpos() local pos = self.object:get_pos()
local item_name = item:get_name() local item_name = item:get_name()
if string.find(item_name, "fishing:pole_") ~= nil then if string.find(item_name, "fishing:pole_") ~= nil then
@ -110,7 +110,7 @@ local FISHING_BOBBER_ENTITY={
end end
end end
-- weither player has fishing pole or not -- 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() self.object:remove()
elseif item_name == "fishing:baitball" then elseif item_name == "fishing:baitball" then
@ -127,14 +127,14 @@ local FISHING_BOBBER_ENTITY={
0.25, 0.5, -- min size, max size 0.25, 0.5, -- min size, max size
false, "fishing_particle_baitball.png") false, "fishing_particle_baitball.png")
-- add sound -- 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
end, end,
-- AS SOON AS THE BOBBER IS PLACED IT WILL ACT LIKE -- AS SOON AS THE BOBBER IS PLACED IT WILL ACT LIKE
on_step = function(self, dtime) 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 --remove if no owner, no player, owner no in bobber_view_range
if self.owner == nil then self.object:remove(); return end if self.owner == nil then self.object:remove(); return end
--remove if not node water --remove if not node water
@ -148,7 +148,7 @@ local FISHING_BOBBER_ENTITY={
end end
local player = minetest.get_player_by_name(self.owner) local player = minetest.get_player_by_name(self.owner)
if not player then self.object:remove(); return end 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 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 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:getpos(),gain = 0.5,})
@ -158,7 +158,7 @@ local FISHING_BOBBER_ENTITY={
--rotate bobber --rotate bobber
if math.random(1, 4) == 1 then 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 end
self.timer = self.timer + 1 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.prize ~= "" and math.random(1,3) == 1 then
if self.old_pos2 == true then if self.old_pos2 == true then
pos.y = pos.y-0.0280 pos.y = pos.y-0.0280
self.object:moveto(pos, false) self.object:move_to(pos, false)
self.old_pos2 = false self.old_pos2 = false
else else
pos.y = pos.y+0.0280 pos.y = pos.y+0.0280
self.object:moveto(pos, false) self.object:move_to(pos, false)
self.old_pos2 = true self.old_pos2 = true
end end
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]) minetest.add_entity({x=pos.x, y=pos.y-1, z=pos.z}, self.prize[1]..":"..self.prize[2])
end end
self.prize = "" 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% --Once the fish are not hungry :), baitball increase hungry + 20%
if math.random(1, 100) > fishing_setting.baits[self.bait]["hungry"] + self.baitball then if math.random(1, 100) > fishing_setting.baits[self.bait]["hungry"] + self.baitball then
--Fish not hungry !( --Fish not hungry !(
@ -221,7 +221,7 @@ local FISHING_BOBBER_ENTITY={
if self.prize ~= "" then if self.prize ~= "" then
pos.y = self.old_pos.y-0.1 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,}) minetest.sound_play("fishing_bobber1", {pos=pos,gain = 0.5,})
end end
end, end,