mirror of
https://github.com/MinetestForFun/fishing.git
synced 2025-07-22 18:10:27 +02:00
fix typo
add support to modpack mobs_fish and mobs_sharks, fish|sharks mobs can be now catched re-add craft worms with 2 dirt
This commit is contained in:
53
bobber.lua
53
bobber.lua
@ -48,14 +48,18 @@ local FISHING_BOBBER_ENTITY={
|
||||
-- DESTROY BOBBER WHEN PUNCHING IT
|
||||
on_punch = function (self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
if not puncher:is_player() then return end
|
||||
local player = puncher:get_player_name()
|
||||
if playername ~= self.owner then return end
|
||||
if fishing_setting.settings["message"] == true then minetest.chat_send_player(playername, fishing_setting.func.S("You didn't catch anything."), false) end
|
||||
local player_name = puncher:get_player_name()
|
||||
if player_name ~= self.owner then return end
|
||||
if fishing_setting.settings["message"] == true then
|
||||
minetest.chat_send_player(player_name, fishing_setting.func.S("You didn't catch anything."), false)
|
||||
end
|
||||
if not fishing_setting.is_creative_mode then
|
||||
local inv = puncher:get_inventory()
|
||||
if inv:room_for_item("main", {name=self.bait, count=1, wear=0, metadata=""}) then
|
||||
inv:add_item("main", {name=self.bait, count=1, wear=0, metadata=""})
|
||||
if fishing_setting.settings["message"] == true then minetest.chat_send_player(playername, fishing_setting.func.S("The bait is still there."), false) end
|
||||
if fishing_setting.settings["message"] == true then
|
||||
minetest.chat_send_player(player_name, fishing_setting.func.S("The bait is still there."), false)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- make sound and remove bobber
|
||||
@ -67,19 +71,19 @@ local FISHING_BOBBER_ENTITY={
|
||||
-- WHEN RIGHTCLICKING THE BOBBER THE FOLLOWING HAPPENS (CLICK AT THE RIGHT TIME WHILE HOLDING A FISHING POLE)
|
||||
on_rightclick = function (self, clicker)
|
||||
local item = clicker:get_wielded_item()
|
||||
local playername = clicker:get_player_name()
|
||||
local player_name = clicker:get_player_name()
|
||||
local inv = clicker:get_inventory()
|
||||
local pos = self.object:getpos()
|
||||
local item_name = item:get_name()
|
||||
if string.find(item_name, "fishing:pole_") ~= nil then
|
||||
if playername ~= self.owner then return end
|
||||
if player_name ~= self.owner then return end
|
||||
if self.prize ~= "" then
|
||||
if math.random(1, 100) <= fishing_setting.settings["escape_chance"] then
|
||||
if fishing_setting.settings["message"] == true then minetest.chat_send_player(playername, fishing_setting.func.S("Your fish escaped."), false) end -- fish escaped
|
||||
if fishing_setting.settings["message"] == true then minetest.chat_send_player(player_name, fishing_setting.func.S("Your fish escaped."), false) end -- fish escaped
|
||||
else
|
||||
local name = self.prize[1]..":"..self.prize[2]
|
||||
local desc = self.prize[4]
|
||||
if fishing_setting.settings["message"] == true then minetest.chat_send_player(playername, fishing_setting.func.S("You caught "..desc), false) end
|
||||
if fishing_setting.settings["message"] == true then minetest.chat_send_player(player_name, fishing_setting.func.S("You caught "..desc), false) end
|
||||
fishing_setting.func.add_to_trophies(clicker, self.prize[2], desc)
|
||||
local wear_value = fishing_setting.func.wear_value(self.prize[3])
|
||||
if inv:room_for_item("main", {name=name, count=1, wear=wear_value, metadata=""}) then
|
||||
@ -88,6 +92,12 @@ local FISHING_BOBBER_ENTITY={
|
||||
minetest.spawn_item(clicker:getpos(), {name=name, count=1, wear=wear_value, metadata=""})
|
||||
end
|
||||
end
|
||||
else
|
||||
if not fishing_setting.is_creative_mode then
|
||||
if inv:room_for_item("main", {name=self.bait, count=1, wear=0, metadata=""}) then
|
||||
inv:add_item("main", {name=self.bait, count=1, wear=0, metadata=""})
|
||||
end
|
||||
end
|
||||
end
|
||||
-- weither player has fishing pole or not
|
||||
minetest.sound_play("fishing_bobber1", { pos = self.object:getpos(), gain = 0.5, })
|
||||
@ -120,7 +130,9 @@ local FISHING_BOBBER_ENTITY={
|
||||
--remove if not node water
|
||||
local node = minetest.get_node_or_nil({x=pos.x, y=pos.y-0.5, z=pos.z})
|
||||
if not node or string.find(node.name, "water_source") == nil then
|
||||
if fishing_setting.settings["message"] == true then minetest.chat_send_player(self.owner, "Haha, Fishing is prohibited outside water!") end
|
||||
if fishing_setting.settings["message"] == true then
|
||||
minetest.chat_send_player(self.owner, "Haha, Fishing is prohibited outside water!")
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
@ -158,6 +170,9 @@ local FISHING_BOBBER_ENTITY={
|
||||
|
||||
--change item on line
|
||||
self.timer = 0
|
||||
if self.prize ~= "" and fishing_setting.have_true_fish and fishing_setting.prizes["true_fish"]["little"][self.prize[1]..":"..self.prize[2]] then
|
||||
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)
|
||||
--Once the fish are not hungry :), baitball increase hungry + 20%
|
||||
@ -174,10 +189,24 @@ local FISHING_BOBBER_ENTITY={
|
||||
else
|
||||
self.prize = fishing_setting.prizes["rivers"]["little"][math.random(1,#fishing_setting.prizes["rivers"]["little"])]
|
||||
end
|
||||
else
|
||||
if math.random(1, 100) <= 10 then
|
||||
self.prize = fishing_setting.func.get_loot()
|
||||
|
||||
-- to mobs_fish modpack
|
||||
if fishing_setting.have_true_fish then
|
||||
local objs = minetest.get_objects_inside_radius({x=pos.x, y=pos.y-1, z=pos.z}, 1)
|
||||
for _, obj in pairs(objs) do
|
||||
if obj:get_luaentity() ~= nil then
|
||||
local name = obj:get_luaentity().name
|
||||
if fishing_setting.prizes["true_fish"]["little"][name] then
|
||||
self.prize = fishing_setting.prizes["true_fish"]["little"][name]
|
||||
obj:remove()
|
||||
self.randomtime = math.random(3,7)*10
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif math.random(1, 100) <= 10 then
|
||||
self.prize = fishing_setting.func.get_loot()
|
||||
end
|
||||
|
||||
if self.prize ~= "" then
|
||||
|
Reference in New Issue
Block a user