diff --git a/baits.lua b/baits.lua index 092e3ac..f5eeb72 100755 --- a/baits.lua +++ b/baits.lua @@ -28,3 +28,10 @@ fishing_setting.baits["fishing:clownfish_raw"] = { ["bait"] = "fishing:clownfish fishing_setting.baits["fishing:bluewhite_raw"] = { ["bait"] = "fishing:bluewhite_raw", ["bobber"] = "fishing:bobber_shark_entity",["texture"] = "fishing_bluewhite_raw.png", ["hungry"] = 50 } fishing_setting.baits["fishing:exoticfish_raw"] = { ["bait"] = "fishing:exoticfish_raw", ["bobber"] = "fishing:bobber_shark_entity",["texture"] = "fishing_exoticfish_raw.png", ["hungry"] = 50 } + +-- to mob_fish modpack +if (minetest.get_modpath("mobs_fish")) then + fishing_setting.baits["mobs_fish:clownfish"] = { ["bait"] = "mobs_fish:clownfish", ["bobber"] = "fishing:bobber_shark_entity", ["hungry"] = 50 } + fishing_setting.baits["mobs_fish:tropical"] = { ["bait"] = "mobs_fish:tropical", ["bobber"] = "fishing:bobber_shark_entity", ["hungry"] = 50 } +end + diff --git a/bobber.lua b/bobber.lua index 6cfce3f..0583368 100755 --- a/bobber.lua +++ b/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 diff --git a/bobber_shark.lua b/bobber_shark.lua index 6a556dc..453c162 100755 --- a/bobber_shark.lua +++ b/bobber_shark.lua @@ -48,12 +48,16 @@ local FISHING_BOBBER_SHARK_ENTITY={ if not puncher:is_player() then return 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 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(player_name, 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 @@ -86,6 +90,12 @@ local FISHING_BOBBER_SHARK_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, }) @@ -118,7 +128,9 @@ local FISHING_BOBBER_SHARK_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, fishing_setting.func.S("Haha, Fishing is prohibited outside water!")) end + if fishing_setting.settings["message"] == true then + minetest.chat_send_player(self.owner, fishing_setting.func.S("Haha, Fishing is prohibited outside water!")) + end self.object:remove() return end @@ -156,6 +168,9 @@ local FISHING_BOBBER_SHARK_ENTITY={ --change item on line self.timer = 0 + if self.prize ~= "" and fishing_setting.have_true_fish and fishing_setting.prizes["true_fish"]["big"][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% @@ -168,8 +183,8 @@ local FISHING_BOBBER_SHARK_ENTITY={ self.randomtime = math.random(1,5)*10 local chance = math.random(1, 100) --if 1 you catch a treasure - if chance == 1 then - if math.random(1, 100) <= fishing_setting.settings["treasure_chance"] and fishing_setting.settings["treasure_enable"] then + if fishing_setting.settings["treasure_enable"] and chance == 1 then + if math.random(1, 100) <= fishing_setting.settings["treasure_chance"] then self.prize = fishing_setting.prizes["treasure"][math.random(1,#fishing_setting.prizes["treasure"])] end elseif chance <= fishing_setting.settings["fish_chance"] then @@ -178,10 +193,24 @@ local FISHING_BOBBER_SHARK_ENTITY={ else self.prize = fishing_setting.prizes["rivers"]["big"][math.random(1,#fishing_setting.prizes["rivers"]["big"])] 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-2, z=pos.z}, 3) + for _, obj in pairs(objs) do + if obj:get_luaentity() ~= nil then + local name = obj:get_luaentity().name + if fishing_setting.prizes["true_fish"]["big"][name] then + self.prize = fishing_setting.prizes["true_fish"]["big"][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 diff --git a/crafting.lua b/crafting.lua index 6a502ef..7967645 100755 --- a/crafting.lua +++ b/crafting.lua @@ -127,6 +127,21 @@ minetest.register_craft({ cooktime = 2, }) +if minetest.get_modpath("mobs_fish") ~= nil then + minetest.register_craft({ + type = "cooking", + output = "fishing:fish_cooked", + recipe = "mobs_fish:clownfish", + cooktime = 2, + }) + minetest.register_craft({ + type = "cooking", + output = "fishing:fish_cooked", + recipe = "mobs_fish:tropical", + cooktime = 2, + }) +end + ----------------------------------------------------------------------------------------------- -- Wheat Seed ----------------------------------------------------------------------------------------------- @@ -166,6 +181,27 @@ minetest.register_craft({ cooktime = 2, }) +if minetest.get_modpath("mobs_sharks") ~= nil then + minetest.register_craft({ + type = "cooking", + output = "fishing:shark_cooked", + recipe = "mobs_sharks:shark_lg", + cooktime = 2, + }) + minetest.register_craft({ + type = "cooking", + output = "fishing:shark_cooked", + recipe = "mobs_sharks:shark_md", + cooktime = 2, + }) + minetest.register_craft({ + type = "cooking", + output = "fishing:shark_cooked", + recipe = "mobs_sharks:shark_sm", + cooktime = 2, + }) +end + ----------------------------------------------------------------------------------------------- -- Roasted Pike ----------------------------------------------------------------------------------------------- diff --git a/depends.txt b/depends.txt index 6b8e3db..ea5ce40 100755 --- a/depends.txt +++ b/depends.txt @@ -7,3 +7,5 @@ moreores? mobs? flowers_plus? seaplants? +mobs_fish? +mobs_sharks? diff --git a/functions.lua b/functions.lua index b42901c..f313bd5 100755 --- a/functions.lua +++ b/functions.lua @@ -102,8 +102,19 @@ end --function random hungry by bait type function fishing_setting.func.hungry_random() for i,a in pairs(fishing_setting.baits) do - fishing_setting.baits[i]["hungry"] = math.random(15, 80) + if string.find(i, "fishing:") ~= nil then + fishing_setting.baits[i]["hungry"] = math.random(15, 80) + end end + + -- to mobs_fish modpack + if fishing_setting.baits["mobs_fish:clownfish"] then + fishing_setting.baits["mobs_fish:clownfish"]["hungry"] = fishing_setting.baits["fishing:clownfish_raw"]["hungry"] + end + if fishing_setting.baits["mobs_fish:tropical"] then + fishing_setting.baits["mobs_fish:tropical"]["hungry"] = fishing_setting.baits["fishing:exoticfish_raw"]["hungry"] + end + --change hungry after random time, min 0h30, max 6h00 minetest.after(math.random(1, 12)*1800,function() fishing_setting.func.hungry_random() end) end @@ -344,22 +355,23 @@ end) function fishing_setting.func.add_to_trophies(player, fish, desc) local player_name = player:get_player_name() if not player_name then return end - if string.find(fish, "_raw") ~= nil then - if fishing_setting.trophies[fish] == nil then - fishing_setting.trophies[fish] = {} - end - fishing_setting.trophies[fish][player_name] = (fishing_setting.trophies[fish][player_name] or 0) + 1 - if fishing_setting.trophies[fish][player_name]%100 == 0 then - minetest.chat_send_player(player_name, S("You win a new trophy, you have caught %s " .. fish.."."):format(fishing_setting.trophies[fish][player_name])) - local inv = player:get_inventory() - local name = "fishing:trophy_"..fish - 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=""}) + if string.find(fish, "_raw") ~= nil or fishing_setting.prizes["true_fish"]["little"][fish] or fishing_setting.prizes["true_fish"]["big"][fish] then + if string.find(fish, "_raw") ~= nil then + if fishing_setting.trophies[fish] == nil then + fishing_setting.trophies[fish] = {} + end + fishing_setting.trophies[fish][player_name] = (fishing_setting.trophies[fish][player_name] or 0) + 1 + if fishing_setting.trophies[fish][player_name]%100 == 0 then + minetest.chat_send_player(player_name, S("You win a new trophy, you have caught %s " .. fish.."."):format(fishing_setting.trophies[fish][player_name])) + local inv = player:get_inventory() + local name = "fishing:trophy_"..fish + 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=""}) + end end end - if fishing_setting.contest["contest"] ~= nil and fishing_setting.contest["contest"] == true then if fishing_setting.contest["nb_fish"] == nil then fishing_setting.contest["nb_fish"] = {} @@ -582,9 +594,11 @@ function fishing_setting.func.get_hunger_info(player_name) local formspec = "size[6,9]label[1.9,0;Fishing Info Center]" local y = 0.8 for i, a in pairs(fishing_setting.baits) do - formspec = formspec .."item_image_button[1,"..tostring(y)..";1,1;"..tostring(i)..";"..tostring(i)..";]".. - "label[2.2,"..tostring(y+0.2)..";Chance to fish :"..tostring(a["hungry"]).."%]" - y = y+1 + if string.find(i, "fishing:") ~= nil then + formspec = formspec .."item_image_button[1,"..tostring(y)..";1,1;"..tostring(i)..";"..tostring(i)..";]".. + "label[2.2,"..tostring(y+0.2)..";Chance to fish :"..tostring(a["hungry"]).."%]" + y = y+1 + end end formspec = formspec .."button_exit[2,8.5;2,1;close;"..S("Close").."]" minetest.show_formspec(player_name,"fishing:material_info", formspec) diff --git a/init.lua b/init.lua index 7e12ca9..8dc46c0 100755 --- a/init.lua +++ b/init.lua @@ -1,6 +1,6 @@ ----------------------------------------------------------------------------------------------- local title = "Fishing - Crabman77's version" -local version = "0.0.3" +local version = "0.0.4" local mname = "fishing" ----------------------------------------------------------------------------------------------- -- original by wulfsdad (http://forum.minetest.net/viewtopic.php?id=4375) @@ -55,6 +55,11 @@ fishing_setting.settings["treasure_chance"] = TREASURE_CHANCE fishing_setting.settings["treasure_enable"] = TREASURE_RANDOM_ENABLE fishing_setting.settings["escape_chance"] = ESCAPE_CHANCE +-- to mobs_fish|mobs_sharks modpack +if (minetest.get_modpath("mobs_fish") ~= nil or minetest.get_modpath("mobs_sharks") ~= nil) then + fishing_setting.have_true_fish = true +end + -- load config file if exist in worldpath fishing_setting.func.load() diff --git a/locale/de.txt b/locale/de.txt index f690368..62b9765 100755 --- a/locale/de.txt +++ b/locale/de.txt @@ -8,6 +8,11 @@ Your fish escaped. = Dein Fisch ist entkommen. You caught a Fish. = Du hast einen Fisch gefangen. You caught a Clownfish. = Du hast einen Clownfisch gefangen. You caught a Bluewhite. = Du hast einen blau-weissen Fisch gefangen. +You caught a Carp. = +You caught a Perch. = +You caught a Catfish. = +You caught a Exoticfish. = +You caught a tropical fish. = You caught a Twig. = Du hast einen Zweig gefangen. You caught a Rat. = Du hast eine Ratte gefangen. You caught some Seaweed. = Du hast etwas Seetang gefangen. diff --git a/locale/fr.txt b/locale/fr.txt index cb55e4c..1e29bc1 100755 --- a/locale/fr.txt +++ b/locale/fr.txt @@ -14,7 +14,8 @@ You caught a Carp. = Vous avez attrape une carpe. You caught a Perch. = Vous avez attrape une perche. You caught a Catfish. = Vous avez attrape un poisson chat. You caught a Exoticfish. = Vous avez attrape un poisson exotic. -You caught a Twig. = Vous avez attrape une brindille . +You caught a Tropical fish. = Vous avez attrape un poisson tropicale. +You caught a Twig. = Vous avez attrape une brindille. You caught a Rat. = Vous avez attrape un rat. You caught some Seaweed. = Vous avez attrape des algues. You caught a Green Kelp. = Vous avez attrape une algue verte. diff --git a/locale/template.txt b/locale/template.txt index 44fb399..adb712d 100755 --- a/locale/template.txt +++ b/locale/template.txt @@ -10,10 +10,12 @@ The bait is still there. = Your fish escaped. = You caught a Fish. = You caught a Clownfish. = +You caught a Bluewhite. = You caught a Carp. = You caught a Perch. = You caught a Catfish. = You caught a Exoticfish. = +You caught a tropical fish. = You caught a Twig. = You caught a Rat. = You caught some Seaweed. = diff --git a/prizes.lua b/prizes.lua index 65a09b7..1019bbc 100755 --- a/prizes.lua +++ b/prizes.lua @@ -24,7 +24,6 @@ fishing_setting.prizes["sea"]["big"] = { } - local stuff = { -- mod item wear message ("You caught "..) nrmin chance (1/67) {"flowers", "seaweed", 0, "some Seaweed.", 1, 5}, @@ -57,3 +56,18 @@ local treasure = { } fishing_setting.prizes["treasure"] = fishing_setting.func.ignore_mod(treasure) + +-- to true fish mobs +fishing_setting.prizes["true_fish"] = {little = {}, big = {}} +--to mobs_fish modpack +if (minetest.get_modpath("mobs_fish")) then + fishing_setting.prizes["true_fish"]["little"]["mobs_fish:clownfish"] = {"mobs_fish", "clownfish", 0, "a Clownfish."} + fishing_setting.prizes["true_fish"]["little"]["mobs_fish:tropical"] = {"mobs_fish", "tropical", 0, "a tropical fish."} +end +--to mobs_fish modpack +if (minetest.get_modpath("mobs_sharks")) then + fishing_setting.prizes["true_fish"]["big"]["mobs_sharks:shark_lg"] = {"mobs_sharks", "shark_lg", 0, "a small Shark."} + fishing_setting.prizes["true_fish"]["big"]["mobs_sharks:shark_md"] = {"mobs_sharks", "shark_md", 0, "a small Shark."} + fishing_setting.prizes["true_fish"]["big"]["mobs_sharks:shark_sm"] = {"mobs_sharks", "shark_sm", 0, "a small Shark."} +end + diff --git a/worms.lua b/worms.lua index 7693c06..d7a701f 100755 --- a/worms.lua +++ b/worms.lua @@ -122,6 +122,15 @@ minetest.register_entity("fishing:bait_worm_entity", { end, }) +--- Bait Worm Entity +minetest.register_craft({ + output = "fishing:bait_worm 8", + recipe = { + {"default:dirt"}, + {"default:dirt"}, + } +}) + ----------------------------------------------------------------------------------------------- -- GETTING WORMS -----------------------------------------------------------------------------------------------