From 3af28b21b7f0a0ce6d86e46aeed55f01942dcb66 Mon Sep 17 00:00:00 2001 From: crabman77 Date: Fri, 26 Jun 2015 22:33:51 +0200 Subject: [PATCH] finished rewriting --- README.md | 11 +- amorce.lua | 19 -- baitball.lua | 56 +++- baits.lua | 21 +- bobber.lua | 73 ++--- bobber_shark.lua | 194 +++++++++++++ chatcommands.lua | 88 ------ crafting.lua | 209 +++++++++++++- depends.txt | 7 + fishes.lua | 44 ++- functions.lua | 256 ++++++++++-------- init.lua | 62 ++--- locale/de.txt | 67 +++-- locale/fr.txt | 85 ++++++ locale/template.txt | 80 ++++-- material.lua | 35 +++ poles.lua | 17 +- prizes.lua | 36 ++- random_object.lua | 3 - settings.txt | 2 +- textures/alternates/fishing_bobber_bottom.png | Bin 207 -> 0 bytes textures/alternates/fishing_bobber_top.png | Bin 193 -> 0 bytes textures/alternates/fishing_pole.png | Bin 295 -> 0 bytes textures/fishing_bait_bread.png | Bin 0 -> 596 bytes textures/fishing_bait_corn.png | Bin ...fishing_worm.png => fishing_bait_worm.png} | Bin textures/fishing_baitball.png | Bin textures/fishing_baitball_shark.png | Bin 0 -> 569 bytes ...ue_white_item.png => fishing_bluefish.png} | Bin textures/fishing_bobber.png | Bin textures/fishing_bobber_bottom.png | Bin textures/fishing_bobber_feather_1.png | Bin ...ng_bobber.png => fishing_bobber_shark.png} | Bin textures/fishing_bobber_top.png | Bin ...ownfish_item.png => fishing_clownfish.png} | Bin textures/fishing_deco_pike.png | Bin textures/fishing_fish.png | Bin textures/fishing_fish_cooked.png | Bin textures/fishing_particle_baitball.png | Bin textures/fishing_particle_baitball_shark.png | Bin 0 -> 223 bytes textures/fishing_pike.png | Bin textures/fishing_pike_cooked.png | Bin textures/fishing_pole_perfect.png | Bin textures/fishing_pole_perfect_back.png | Bin textures/fishing_pole_perfect_bottom.png | Bin textures/fishing_pole_perfect_front.png | Bin textures/fishing_pole_perfect_simple.png | Bin textures/fishing_pole_perfect_top.png | Bin textures/fishing_pole_wood.png | Bin textures/fishing_pole_wood_back.png | Bin textures/fishing_pole_wood_bottom.png | Bin textures/fishing_pole_wood_deco.png | Bin textures/fishing_pole_wood_front.png | Bin textures/fishing_pole_wood_simple.png | Bin textures/fishing_pole_wood_top.png | Bin textures/fishing_shark.png | Bin textures/fishing_shark_cooked.png | Bin textures/fishing_sushi.png | Bin textures/fishing_trophy_label.png | Bin .../not_in_use/fishing_bobber_feather_1.png | Bin 352 -> 0 bytes .../not_in_use/fishing_bobber_feather_2.png | Bin 363 -> 0 bytes textures/not_in_use/fishing_bobber_ready.png | Bin 222 -> 0 bytes textures/not_in_use/fishing_pole_on_use.png | Bin 238 -> 0 bytes textures/old/fishing_bobber_alternate_old.png | Bin 217 -> 0 bytes textures/old/fishing_bobber_old.png | Bin 238 -> 0 bytes textures/old/fishing_pole_wield.png | Bin 269 -> 0 bytes textures/old/fishing_shark_old6.png | Bin 391 -> 0 bytes trophies.lua | 84 ++++++ worms.lua | 245 +++++++++++++++++ 69 files changed, 1296 insertions(+), 398 deletions(-) delete mode 100644 amorce.lua create mode 100644 bobber_shark.lua delete mode 100644 chatcommands.lua create mode 100644 locale/fr.txt create mode 100644 material.lua delete mode 100644 random_object.lua delete mode 100644 textures/alternates/fishing_bobber_bottom.png delete mode 100644 textures/alternates/fishing_bobber_top.png delete mode 100644 textures/alternates/fishing_pole.png create mode 100755 textures/fishing_bait_bread.png mode change 100644 => 100755 textures/fishing_bait_corn.png rename textures/{fishing_worm.png => fishing_bait_worm.png} (100%) mode change 100644 => 100755 mode change 100644 => 100755 textures/fishing_baitball.png create mode 100755 textures/fishing_baitball_shark.png rename textures/{animal_fish_blue_white_fish_blue_white_item.png => fishing_bluefish.png} (100%) mode change 100644 => 100755 mode change 100644 => 100755 textures/fishing_bobber.png mode change 100644 => 100755 textures/fishing_bobber_bottom.png mode change 100644 => 100755 textures/fishing_bobber_feather_1.png rename textures/{alternates/fishing_bobber.png => fishing_bobber_shark.png} (100%) mode change 100644 => 100755 mode change 100644 => 100755 textures/fishing_bobber_top.png rename textures/{animal_clownfish_clownfish_item.png => fishing_clownfish.png} (100%) mode change 100644 => 100755 mode change 100644 => 100755 textures/fishing_deco_pike.png mode change 100644 => 100755 textures/fishing_fish.png mode change 100644 => 100755 textures/fishing_fish_cooked.png mode change 100644 => 100755 textures/fishing_particle_baitball.png create mode 100755 textures/fishing_particle_baitball_shark.png mode change 100644 => 100755 textures/fishing_pike.png mode change 100644 => 100755 textures/fishing_pike_cooked.png mode change 100644 => 100755 textures/fishing_pole_perfect.png mode change 100644 => 100755 textures/fishing_pole_perfect_back.png mode change 100644 => 100755 textures/fishing_pole_perfect_bottom.png mode change 100644 => 100755 textures/fishing_pole_perfect_front.png mode change 100644 => 100755 textures/fishing_pole_perfect_simple.png mode change 100644 => 100755 textures/fishing_pole_perfect_top.png mode change 100644 => 100755 textures/fishing_pole_wood.png mode change 100644 => 100755 textures/fishing_pole_wood_back.png mode change 100644 => 100755 textures/fishing_pole_wood_bottom.png mode change 100644 => 100755 textures/fishing_pole_wood_deco.png mode change 100644 => 100755 textures/fishing_pole_wood_front.png mode change 100644 => 100755 textures/fishing_pole_wood_simple.png mode change 100644 => 100755 textures/fishing_pole_wood_top.png mode change 100644 => 100755 textures/fishing_shark.png mode change 100644 => 100755 textures/fishing_shark_cooked.png mode change 100644 => 100755 textures/fishing_sushi.png mode change 100644 => 100755 textures/fishing_trophy_label.png delete mode 100644 textures/not_in_use/fishing_bobber_feather_1.png delete mode 100644 textures/not_in_use/fishing_bobber_feather_2.png delete mode 100644 textures/not_in_use/fishing_bobber_ready.png delete mode 100644 textures/not_in_use/fishing_pole_on_use.png delete mode 100644 textures/old/fishing_bobber_alternate_old.png delete mode 100644 textures/old/fishing_bobber_old.png delete mode 100644 textures/old/fishing_pole_wield.png delete mode 100644 textures/old/fishing_shark_old6.png diff --git a/README.md b/README.md index 65c1527..42889cf 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,9 @@ minetest fishing mod -NOT STABLE VERSION - -DO NO USE - -INCOMPLETE CODE - ---rewriting total in progress... +--rewriting total finished 26/06/2015 +--rewrited by Crabman77 -- original by Mossmanikin https://github.com/Mossmanikin/fishing + + diff --git a/amorce.lua b/amorce.lua deleted file mode 100644 index e34343f..0000000 --- a/amorce.lua +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - --- amorce - -minetest.register_craftitem("fishing:amorce", { - description = "Amorce", - inventory_image = "fishing_amorce.png", -}) - -minetest.register_craft({ - type = "shapeless", - output = "fishing:amorce", - recipe = {"farming:flour", "farming:corn", "food:egg", "bucket:bucket_water"} -}) diff --git a/baitball.lua b/baitball.lua index 80baefe..e539fd7 100644 --- a/baitball.lua +++ b/baitball.lua @@ -2,18 +2,60 @@ - - - -- baitball - minetest.register_craftitem("fishing:baitball", { - description = "Bait Ball", + description = fishing_setting.func.S("Bait Ball"), inventory_image = "fishing_baitball.png", + stack_max = 99, }) minetest.register_craft({ type = "shapeless", - output = "fishing:baitball", - recipe = {"farming:flour", "farming:corn", "food:egg", "bucket:bucket_water"} + output = "fishing:baitball 20", + recipe = {"farming:flour", "farming:corn", "bucket:bucket_water"}, + replacements = {{ "bucket:bucket_water", "bucket:bucket_empty"}} +}) + + +-- baitball_shark +minetest.register_craftitem("fishing:baitball_shark", { + description = fishing_setting.func.S("Shark Bait Ball"), + inventory_image = "fishing_baitball_shark.png", + stack_max = 99, +}) + +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball_shark 20", + recipe = {"fishing:fish", "fishing:fish"} +}) + +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball_shark 20", + recipe = {"fishing:shark", "fishing:shark"} +}) + +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball_shark 20", + recipe = {"fishing:pike", "fishing:pike"} +}) + +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball_shark 20", + recipe = {"fishing:fish", "fishing:shark"} +}) + +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball_shark 20", + recipe = {"fishing:fish", "fishing:pike"} +}) + +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball_shark 20", + recipe = {"fishing:shark", "fishing:pike"} }) diff --git a/baits.lua b/baits.lua index 4b59d1a..84b175d 100644 --- a/baits.lua +++ b/baits.lua @@ -1,5 +1,4 @@ - --fish bait --bait_corn minetest.register_craftitem("fishing:bait_corn", { @@ -7,25 +6,23 @@ minetest.register_craftitem("fishing:bait_corn", { inventory_image = "fishing_bait_corn.png", }) -fishing_setting.baits["fishing:bait_corn"] = { ["bait"] = "fishing:bait_corn", ["bobber"] = "fishing:bobber_entity", ["hungry"] = 50 } - +fishing_setting.baits["fishing:bait_corn"] = { ["bait"] = "fishing:bait_corn", ["bobber"] = "fishing:bobber_fish_entity",["texture"] = "fishing_bait_corn.png", ["hungry"] = 50 } --bait_bread minetest.register_craftitem("fishing:bait_bread", { description = "Bait Bread", - inventory_image = "fishing_bait_corn.png", + inventory_image = "fishing_bait_bread.png", }) -fishing_setting.baits["fishing:bait_bread"] = { ["bait"] = "fishing:bait_bread", ["bobber"] = "fishing:bobber_entity", ["hungry"] = 50 } - +fishing_setting.baits["fishing:bait_bread"] = { ["bait"] = "fishing:bait_bread", ["bobber"] = "fishing:bobber_fish_entity",["texture"] = "fishing_bait_bread.png", ["hungry"] = 50 } --bait_worm -fishing_setting.baits["fishing:bait_worm"] = { ["bait"] = "fishing:bait_worm", ["bobber"] = "fishing:bobber_entity", ["hungry"] = 50 } - - - - +fishing_setting.baits["fishing:bait_worm"] = { ["bait"] = "fishing:bait_worm", ["bobber"] = "fishing:bobber_fish_entity",["texture"] = "fishing_bait_worm.png", ["hungry"] = 50 } --shark bait --bait_fish -fishing_setting.baits["fishing:bait_fish"] = { ["bait"] = "fishing:bait_fish", ["bobber"] = "fishing:bobber_entity_shark", ["hungry"] = 50 } +fishing_setting.baits["fishing:fish"] = { ["bait"] = "fishing:fish", ["bobber"] = "fishing:bobber_shark_entity",["texture"] = "fishing_fish.png", ["hungry"] = 50 } + +fishing_setting.baits["fishing:clownfish"] = { ["bait"] = "fishing:clownfish", ["bobber"] = "fishing:bobber_shark_entity",["texture"] = "fishing_clownfish.png", ["hungry"] = 50 } +fishing_setting.baits["fishing:bluefish"] = { ["bait"] = "fishing:bluefish", ["bobber"] = "fishing:bobber_shark_entity",["texture"] = "fishing_bluefish.png", ["hungry"] = 50 } + diff --git a/bobber.lua b/bobber.lua index e9b6234..4df8db5 100644 --- a/bobber.lua +++ b/bobber.lua @@ -1,3 +1,10 @@ +----------------------------------------------------------------------------------------------- +-- Fishing - crabman77's version - Bobber +-- Rewrited from original Fishing - Mossmanikin's version - Bobber 0.1.7 +-- License (code & textures): WTFPL +-- Contains code from: fishing (original), mobs, throwing, volcano +-- Supports: 3d_armor, animal_clownfish, animal_fish_blue_white, animal_rat, flowers_plus, mobs, seaplants +----------------------------------------------------------------------------------------------- -- bobber minetest.register_node("fishing:bobber_box", { @@ -7,8 +14,8 @@ minetest.register_node("fishing:bobber_box", { fixed = { -- { left, bottom, front, right, top , back} {-8/16, -8/16, 0, 8/16, 8/16, 0}, -- feathers - {-2/16, -8/16, -2/16, 2/16, -4/16, 2/16}, -- bobber - } + {-2/16, -8/16, -2/16, 2/16, -4/16, 2/16}, -- bobber + }, }, tiles = { "fishing_bobber_top.png", @@ -32,57 +39,61 @@ local FISHING_BOBBER_ENTITY={ visual_size = {x=1/3, y=1/3, z=1/3}, textures = {"fishing:bobber_box"}, -- {left ,bottom, front, right, top , back} - collisionbox = {-2/16, -4/16, -2/16, 2/16, 0/16, 2/16}, + collisionbox = {-2/16, -4/16, -2/16, 2/16, 1/16, 2/16}, randomtime = 50, baitball = 0, prize = "", bait = "", - + -- 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 player ~= self.owner then return end - if fishing_setting.settings["message"] == true then minetest.chat_send_player(player, fishing_setting.func.S("You didn't prizes anything."), false) end + 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 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, fishing_setting.func.S("The bait is still there."), false) end + if fishing_setting.settings["message"] == true then minetest.chat_send_player(playername, fishing_setting.func.S("The bait is still there."), false) end end end -- make sound and remove bobber minetest.sound_play("fishing_bobber1", { pos = self.object:getpos(), gain = 0.5, }) self.object:remove() end, - - + + -- 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 player = clicker:get_player_name() + local playername = 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 player ~= self.owner then return end + if playername ~= self.owner then return end if self.prize ~= "" then - local name = self.prize[1]..":"..self.prize[2] - local desc = self.prize[4] - minetest.chat_send_player(player, "You caught "..desc, false) - 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 - inv:add_item("main", {name=name, count=1, wear=wear_value, metadata=""}) + 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 else - minetest.spawn_item(clicker:getpos(), {name=name, count=1, wear=wear_value, metadata=""}) + 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 + fishing_setting.func.add_to_trophies(clicker, self.prize[2]) + 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 + 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=""}) + end end end - -- weither player has fishing pole or not minetest.sound_play("fishing_bobber1", { pos = self.object:getpos(), gain = 0.5, }) self.object:remove() - - elseif item:get_name() == "fishing:baitball" then + + elseif item_name == "fishing:baitball" then if not fishing_setting.is_creative_mode then inv:remove_item("main", "fishing:baitball") end @@ -99,8 +110,8 @@ local FISHING_BOBBER_ENTITY={ minetest.sound_play("fishing_bobber1", {pos = self.object:getpos(), 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() @@ -109,7 +120,7 @@ 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 - minetest.chat_send_player(self.owner, "Haha, Fishing is prohibited outside water!") + 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 @@ -122,12 +133,12 @@ local FISHING_BOBBER_ENTITY={ 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)) end - + self.timer = self.timer + 1 if self.timer < self.randomtime then -- if fish or others items, move bobber to simulate fish on the line @@ -142,9 +153,9 @@ local FISHING_BOBBER_ENTITY={ self.old_pos2 = true end end - return + return end - + --change item on line self.timer = 0 self.prize = "" @@ -155,7 +166,7 @@ local FISHING_BOBBER_ENTITY={ self.randomtime = math.random(20,60)*10 return end - + self.randomtime = math.random(1,5)*10 if math.random(1, 100) <= fishing_setting.settings["fish_chance"] then self.prize = fishing_setting.prizes["fish"][math.random(1,#fishing_setting.prizes["fish"])] @@ -164,7 +175,7 @@ local FISHING_BOBBER_ENTITY={ self.prize = fishing_setting.prizes["plants"][math.random(1,#fishing_setting.prizes["plants"])] end end - + if self.prize ~= "" then pos.y = self.old_pos.y-0.1 self.object:moveto(pos, false) @@ -173,4 +184,4 @@ local FISHING_BOBBER_ENTITY={ end, } -minetest.register_entity("fishing:bobber_entity", FISHING_BOBBER_ENTITY) +minetest.register_entity("fishing:bobber_fish_entity", FISHING_BOBBER_ENTITY) diff --git a/bobber_shark.lua b/bobber_shark.lua new file mode 100644 index 0000000..c8d14f4 --- /dev/null +++ b/bobber_shark.lua @@ -0,0 +1,194 @@ +----------------------------------------------------------------------------------------------- +-- Fishing - crabman77 version - Bobber Shark +-- Rewrited from original Fishing - Mossmanikin's version - Bobber Shark 0.0.6 +-- License (code & textures): WTFPL +----------------------------------------------------------------------------------------------- + +-- bobber shark +minetest.register_node("fishing:bobber_shark_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { +-- { left, bottom, front, right, top , back} + {-8/16, -8/16, 0, 8/16, 8/16, 0}, -- feathers + {-2/16, -8/16, -2/16, 2/16, -4/16, 2/16}, -- bobber + } + }, + tiles = { + "fishing_bobber_top.png", + "fishing_bobber_bottom.png", + "fishing_bobber_shark.png", + "fishing_bobber_shark.png", + "fishing_bobber_shark.png", + "fishing_bobber_shark.png^[transformFX" + }, -- + groups = {not_in_creative_inventory=1}, +}) + + +local FISHING_BOBBER_SHARK_ENTITY={ + hp_max = 605, + water_damage = 1, + physical = true, + timer = 0, + env_damage_timer = 0, + visual = "wielditem", + visual_size = {x=1/3, y=1/3, z=1/3}, + textures = {"fishing:bobber_shark_box"}, + -- {left ,bottom, front, right, top , back} + collisionbox = {-3/16, -4/16, -3/16, 3/16, 4/16, 3/16}, + randomtime = 50, + baitball = 0, + prize = "", + bait = "", + +-- 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 playername = 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 + 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 + end + end + -- make sound and remove bobber + minetest.sound_play("fishing_bobber1", { pos = self.object:getpos(), gain = 0.5, }) + self.object:remove() + end, + + +-- 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 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 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 + 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, "You caught "..desc, false) end + fishing_setting.func.add_to_trophies(clicker, self.prize[2]) + 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 + 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=""}) + end + end + end + -- weither player has fishing pole or not + minetest.sound_play("fishing_bobber1", { pos = self.object:getpos(), gain = 0.5, }) + self.object:remove() + + elseif item_name == "fishing:baitball_shark" then + if not fishing_setting.is_creative_mode then + inv:remove_item("main", "fishing:baitball_shark") + end + self.baitball = 20 + --addparticle + minetest.add_particlespawner(30, 0.5, -- for how long (?) -- Particles on splash + {x=pos.x,y=pos.y-0.0325,z=pos.z}, {x=pos.x,y=pos.y,z=pos.z}, -- position min, pos max + {x=-2,y=-0.0325,z=-2}, {x=2,y=3,z=2}, -- velocity min, vel max + {x=0,y=-3.8,z=0}, {x=0,y=-9.8,z=0}, + 0.3, 1.2, + 0.25, 0.40, -- min size, max size + false, "fishing_particle_baitball_shark.png") + -- add sound + minetest.sound_play("fishing_bobber1", {pos = self.object:getpos(), 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() + --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 + 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 + self.object:remove() + return + end + local player = minetest.get_player_by_name(self.owner) + if not player then self.object:remove(); return end + local p = player:getpos() + 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,}) + 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)) + end + + self.timer = self.timer + 1 + if self.timer < self.randomtime then + -- if fish or others items, move bobber to simulate fish on the line + if self.prize ~= "" and math.random(1,3) == 1 then + if self.old_pos2 == true then + pos.y = pos.y-0.0525 + self.object:moveto(pos, false) + self.old_pos2 = false + else + pos.y = pos.y+0.0525 + self.object:moveto(pos, false) + self.old_pos2 = true + end + end + return + end + + --change item on line + self.timer = 0 + self.prize = "" + self.object:moveto(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 !( + self.randomtime = math.random(20,60)*10 + return + end + + self.randomtime = math.random(1,5)*10 + local chance = math.random(1, 100) + --if 1 you catch a tresor, maybe ... + if chance == 1 then + --You are lucky ? :) + if math.random(1, 100) <= fishing_setting.settings["tresor_chance"] and fishing_setting.settings["tresor_enable"] then + self.prize = fishing_setting.prizes["tresor"][math.random(1,#fishing_setting.prizes["tresor"])] + else + self.prize = fishing_setting.prizes["stuff"][math.random(1,#fishing_setting.prizes["stuff"])] + end + elseif chance <= fishing_setting.settings["fish_chance"] then + self.prize = fishing_setting.prizes["shark"][math.random(1,#fishing_setting.prizes["shark"])] + else + if math.random(1, 100) <= 10 then + self.prize = fishing_setting.prizes["plants"][math.random(1,#fishing_setting.prizes["plants"])] + end + end + + if self.prize ~= "" then + pos.y = self.old_pos.y-0.2 + self.object:moveto(pos, false) + minetest.sound_play("fishing_bobber1", {pos=pos,gain = 0.5,}) + end + end, +} + +minetest.register_entity("fishing:bobber_shark_entity", FISHING_BOBBER_SHARK_ENTITY) diff --git a/chatcommands.lua b/chatcommands.lua deleted file mode 100644 index 1451b6c..0000000 --- a/chatcommands.lua +++ /dev/null @@ -1,88 +0,0 @@ - - - -minetest.register_chatcommand("fishingset", { - params = "", - description = "Display volume menu formspec", - privs = {interact=true}, - func = function(name, param) - if not name then return end - fishing_setting.func.on_show_settings(name) - end -}) - - - - - --FIXME server set fishing enable|disable treasure -minetest.register_chatcommand("fishing_enable", { - params = "", - description = "display trophie of treasure from the water", - privs = {server=true}, - func = function(name, param) - if param == "true" then - fishing_setting.enable = true - minetest.chat_send_player(name, "treasure is enabled") - elseif param == "false" then - fishing_setting.enable = false - minetest.chat_send_player(name, "treasure is disabled") - else - minetest.chat_send_player(name, "treasure is " .. tostring(fishing_setting.enable)) - minetest.chat_send_player(name, "To change, type:/fishing_enable ") - end - - - end -}) - - - - - ---[[ --FIXME server set fishing random timer -minetest.register_chatcommand("fishing_stimer", { - params = "", - description = "display trophie of treasure from the water", - privs = {server=true}, - func = function(name, param) - minetest.chat_send_player(name, "treasure is " .. treasure) - - end -}) -]] - - ---[[ --FIXME server set fishing config -minetest.register_chatcommand("fishing_setting", { - params = "", - description = "display trophie of treasure from the water", - privs = {server=true}, - func = function(name, param) - minetest.chat_send_player(name, "") - - end -}) -]] - - - -minetest.register_chatcommand("fishing_trophies", { - params = "", - description = "display trophie of treasure from the water", - privs = {}, - func = function(name, param) - --FIXME fixed treasure - local tresure = "nothing" - minetest.chat_send_player(name, "treasure is " .. treasure) - - end -}) - - - ---[[ -minetest.register_on_joinplayer(function(player) - local name = player:get_player_name() - -end) -]] diff --git a/crafting.lua b/crafting.lua index af2b2bf..f29932f 100644 --- a/crafting.lua +++ b/crafting.lua @@ -1,3 +1,13 @@ +----------------------------------------------------------------------------------------------- +-- Fishing - crabman77 version +-- Rewrited from original Fishing - Mossmanikin's version - Recipes 0.0.8 +----------------------------------------------------------------------------------------------- +-- License (code & textures): WTFPL +-- Contains code from: animal_clownfish, animal_fish_blue_white, fishing (original), stoneage +-- Looked at code from: +-- Dependencies: default, farming +-- Supports: animal_clownfish, animal_fish_blue_white, animal_rat, mobs +----------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------- -- Fishing Pole @@ -6,9 +16,9 @@ minetest.register_craft({ output = "fishing:pole_wood", recipe = { - {"", "", "group:stick" }, - {"", "group:stick", "farming:string"}, - {"group:stick", "", "farming:string"}, + {"", "", "group:stick" }, + {"", "group:stick", "farming:string" }, + {"group:stick", "", "farming:string" }, } }) @@ -16,9 +26,9 @@ if minetest.get_modpath("moreblocks") ~= nil then minetest.register_craft({ output = "fishing:pole_wood", recipe = { - {"", "", "group:stick" }, - {"", "group:stick", "moreblocks:rope" }, - {"group:stick", "", "moreblocks:rope" }, + {"", "", "group:stick" }, + {"", "group:stick", "moreblocks:rope" }, + {"group:stick", "", "moreblocks:rope" }, } }) end @@ -27,9 +37,9 @@ if minetest.get_modpath("ropes") ~= nil then minetest.register_craft({ output = "fishing:pole_wood", recipe = { - {"", "", "group:stick" }, - {"", "group:stick", "ropes:rope" }, - {"group:stick", "", "ropes:rope" }, + {"", "", "group:stick" }, + {"", "group:stick", "ropes:rope" }, + {"group:stick", "", "ropes:rope" }, } }) end @@ -39,14 +49,13 @@ if minetest.get_modpath("moreores") ~= nil and minetest.get_modpath("mobs") ~= n minetest.register_craft({ output = "fishing:pole_perfect", recipe = { - {"", "", "moreores:mithril_ingot" }, - {"", "moreores:mithril_ingot", "mobs:spider_cobweb" }, - {"moreores:mithril_ingot", "", "mobs:spider_cobweb" }, + {"", "", "moreores:mithril_ingot" }, + {"", "moreores:mithril_ingot", "mobs:spider_cobweb" }, + {"moreores:mithril_ingot", "", "mobs:spider_cobweb" }, } }) end - ----------------------------------------------------------------------------------------------- -- Fishing bait ----------------------------------------------------------------------------------------------- @@ -66,11 +75,181 @@ minetest.register_craft({ } }) +----------------------------------------------------------------------------------------------- +-- Roasted Fish +----------------------------------------------------------------------------------------------- +minetest.register_craft({ + type = "cooking", + output = "fishing:fish_cooked", + recipe = "fishing:fish", + cooktime = 2, +}) + +minetest.register_craft({ + type = "cooking", + output = "fishing:fish_cooked", + recipe = "fishing:clownfish", + cooktime = 2, +}) +minetest.register_craft({ + type = "cooking", + output = "fishing:fish_cooked", + recipe = "fishing:bluefish", + cooktime = 2, +}) + ----------------------------------------------------------------------------------------------- --- Fishing bobber +-- Wheat Seed ----------------------------------------------------------------------------------------------- ---bobber +minetest.register_craft({ + type = "shapeless", + output = "farming:seed_wheat", + recipe = {"farming:wheat"}, +}) + +----------------------------------------------------------------------------------------------- +-- Sushi +----------------------------------------------------------------------------------------------- +if minetest.get_modpath("flowers_plus") ~= nil then + minetest.register_craft({ + type = "shapeless", + output = "fishing:sushi", + recipe = {"fishing:fish_cooked", "farming:seed_wheat", "flowers:seaweed" }, + }) +end + +if minetest.get_modpath("seaplants") ~= nil then + minetest.register_craft({ + type = "shapeless", + output = "fishing:sushi", + recipe = {"fishing:fish_cooked", "farming:seed_wheat", "seaplants:kelpgreen" }, + + }) +end + +----------------------------------------------------------------------------------------------- +-- Roasted Shark +----------------------------------------------------------------------------------------------- +minetest.register_craft({ + type = "cooking", + output = "fishing:shark_cooked", + recipe = "fishing:shark", + cooktime = 2, +}) + +----------------------------------------------------------------------------------------------- +-- Roasted Pike +----------------------------------------------------------------------------------------------- +minetest.register_craft({ + type = "cooking", + output = "fishing:pike_cooked", + recipe = "fishing:pike", + cooktime = 2, +}) + + + +-- baitball +minetest.register_craftitem("fishing:baitball", { + description = fishing_setting.func.S("Bait Ball"), + inventory_image = "fishing_baitball.png", + stack_max = 99, +}) + +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball 20", + recipe = {"farming:flour", "farming:corn", "bucket:bucket_water"}, + replacements = {{ "bucket:bucket_water", "bucket:bucket_empty"}} +}) + + +-- baitball_shark +minetest.register_craftitem("fishing:baitball_shark", { + description = fishing_setting.func.S("Shark Bait Ball"), + inventory_image = "fishing_baitball_shark.png", + stack_max = 99, +}) + +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball_shark 20", + recipe = {"fishing:fish", "fishing:fish"} +}) + +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball_shark 20", + recipe = {"fishing:clownfish", "fishing:clownfish"} +}) + +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball_shark 20", + recipe = {"fishing:clownfish", "fishing:fish"} +}) +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball_shark 20", + recipe = {"fishing:bluefish", "fishing:bluefish"} +}) + +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball_shark 20", + recipe = {"fishing:bluefish", "fishing:fish"} +}) +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball_shark 20", + recipe = {"fishing:clownfish", "fishing:bluefish"} +}) + + +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball_shark 20", + recipe = {"fishing:shark", "fishing:shark"} +}) + +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball_shark 20", + recipe = {"fishing:pike", "fishing:pike"} +}) + +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball_shark 20", + recipe = {"fishing:fish", "fishing:shark"} +}) + +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball_shark 20", + recipe = {"fishing:fish", "fishing:pike"} +}) + +minetest.register_craft({ + type = "shapeless", + output = "fishing:baitball_shark 20", + recipe = {"fishing:shark", "fishing:pike"} +}) + + + + + + + + + + + + + + diff --git a/depends.txt b/depends.txt index d77ba25..6b8e3db 100644 --- a/depends.txt +++ b/depends.txt @@ -1,2 +1,9 @@ default +unified_inventory? farming +moreblocks? +ropes? +moreores? +mobs? +flowers_plus? +seaplants? diff --git a/fishes.lua b/fishes.lua index 07d20d9..407a891 100644 --- a/fishes.lua +++ b/fishes.lua @@ -1,22 +1,22 @@ ------------------------------------------------------------------------------------------- --- Fishing - Mossmanikin's version - Fishes 0.0.4 --- License (code & textures): WTFPL +-- Fishing - crabman77 version +-- Rewrited from original Fishing - Mossmanikin's version - Fishes 0.0.4 +-- License (code & textures): WTFPL ----------------------------------------------------------------------------------------------- - ----------------------------------------------------------------------------------------------- -- Fish ----------------------------------------------------------------------------------------------- -minetest.register_craftitem("fishing:fish_raw", { +minetest.register_craftitem("fishing:fish", { description = fishing_setting.func.S("Fish"), - groups = {}, - inventory_image = "fishing_fish.png", + groups = {}, + inventory_image = "fishing_fish.png", on_use = minetest.item_eat(2), }) ----------------------------------------------------- -- Roasted Fish ----------------------------------------------------- - minetest.register_craftitem("fishing:fish", { + minetest.register_craftitem("fishing:fish_cooked", { description = fishing_setting.func.S("Roasted Fish"), groups = {}, inventory_image = "fishing_fish_cooked.png", @@ -32,13 +32,33 @@ minetest.register_craftitem("fishing:fish_raw", { on_use = minetest.item_eat(6), }) +----------------------------------------------------------------------------------------------- +-- clownfish +----------------------------------------------------------------------------------------------- +minetest.register_craftitem("fishing:clownfish", { + description = fishing_setting.func.S("Clownfish"), + groups = {}, + inventory_image = "fishing_clownfish.png", + on_use = minetest.item_eat(2), +}) + +----------------------------------------------------------------------------------------------- +-- bluefish +----------------------------------------------------------------------------------------------- +minetest.register_craftitem("fishing:bluefish", { + description = fishing_setting.func.S("Bluefish"), + groups = {}, + inventory_image = "fishing_bluefish.png", + on_use = minetest.item_eat(2), +}) + ----------------------------------------------------------------------------------------------- -- Whatthef... it's a freakin' Shark! ----------------------------------------------------------------------------------------------- minetest.register_craftitem("fishing:shark", { description = fishing_setting.func.S("Shark"), - groups = {}, - inventory_image = "fishing_shark.png", + groups = {}, + inventory_image = "fishing_shark.png", on_use = minetest.item_eat(2), }) ----------------------------------------------------- @@ -50,14 +70,14 @@ minetest.register_craftitem("fishing:shark", { inventory_image = "fishing_shark_cooked.png", on_use = minetest.item_eat(6), }) - + ----------------------------------------------------------------------------------------------- -- Pike ----------------------------------------------------------------------------------------------- minetest.register_craftitem("fishing:pike", { description = fishing_setting.func.S("Northern Pike"), - groups = {}, - inventory_image = "fishing_pike.png", + groups = {}, + inventory_image = "fishing_pike.png", on_use = minetest.item_eat(2), }) ----------------------------------------------------- diff --git a/functions.lua b/functions.lua index cf5deb4..9e3b6e3 100644 --- a/functions.lua +++ b/functions.lua @@ -1,12 +1,12 @@ - +--function save settings function fishing_setting.func.save() - local input = io.open(fishing_setting.file, "w") + local input = io.open(fishing_setting.file_settings, "w") if input then input:write(minetest.serialize(fishing_setting.settings)) input:close() else - minetest.log("action","Open failed (mode:w) of " .. fishing_setting.file) + minetest.log("action","Open failed (mode:w) of " .. fishing_setting.file_settings) end end @@ -51,19 +51,20 @@ function fishing_setting.func.set_settings(new_settings, settings) new_settings["shark_chance"] = settings["shark_chance"] end - if settings["tresor_timer"] ~= nil then - new_settings["tresor_timer"] = settings["tresor_timer"] + if settings["tresor_enable"] ~= nil then + new_settings["tresor_enable"] = settings["tresor_enable"] end - if settings["tresor_random_enable"] ~= nil then - new_settings["tresor_random_enable"] = settings["tresor_random_enable"] - end + if settings["escape_chance"] ~= nil then + new_settings["escape_chance"] = settings["escape_chance"] + end + end --function load settings from file function fishing_setting.func.load() - local file = io.open(fishing_setting.file, "r") + local file = io.open(fishing_setting.file_settings, "r") local settings = {} if file then settings = minetest.deserialize(file:read("*all")) @@ -85,95 +86,51 @@ function fishing_setting.func.wear_value(wear) return used end -minetest.register_on_shutdown(function() - minetest.log("action", "[fishing] Server shuts down. Saving config") - fishing_setting.func.save() -end) + +-- function return table where mods actived +function fishing_setting.func.ignore_mod(list) + local listOk = {} + for i,v in ipairs(list) do + if minetest.get_modpath(v[1]) ~= nil then + table.insert(listOk, v) + end + end + return listOk +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) - print("hungry " ..i..": " ..fishing_setting.baits[i]["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 -- show notification when player catch tresor function fishing_setting.func.notify(f_name, tresor) - local title = f_name .." catch a tresor" - + local title = "Good luck to "..f_name ..", He catch the tresor, "..tresor[4].."!" for _, player in ipairs(minetest.get_connected_players()) do - local name = player:get_player_name() - --FIXME display message - --if name == f_name then - -- fishing_setting.func.notify_send(name, tresor, message) - --else - fishing_setting.func.notify_send(name, title, tresor[4]) - --end + local player_name = player:get_player_name() + if player_name == f_name then + minetest.chat_send_player(player_name, "You catch the tresor, "..tresor[4].."!") + else + minetest.chat_send_player(player_name, title) + end end end --- show notification when player catch tresor -function fishing_setting.func.notify_send(name, title, message) - local player = minetest.get_player_by_name(name) - local one = player:hud_add({ - hud_elem_type = "image", - name = "award_bg", - scale = {x = 1, y = 1}, - text = "bg_default.png", - position = {x = 0.5, y = 0}, - offset = {x = 0, y = 138}, - alignment = {x = 0, y = -1} - }) - local two = player:hud_add({ - hud_elem_type = "text", - name = "award_au", - number = 0xFFFFFF, - scale = {x = 100, y = 20}, - text = title, - position = {x = 0.5, y = 0}, - offset = {x = 0, y = 40}, - alignment = {x = 0, y = -1} - }) - local three = player:hud_add({ - hud_elem_type = "text", - name = "award_title", - number = 0xFFFFFF, - scale = {x = 100, y = 20}, - text = message, - position = {x = 0.5, y = 0}, - offset = {x = 30, y = 100}, - alignment = {x = 0, y = -1} - }) - local four = player:hud_add({ - hud_elem_type = "image", - name = "award_icon", - scale = {x = 4, y = 4}, - text = "fishing_pole_perfect.png", - position = {x = 0.5, y = 0}, - offset = {x = -81.5, y = 126}, - alignment = {x = 0, y = -1} - }) - minetest.after(6, function() - player:hud_remove(one) - player:hud_remove(two) - player:hud_remove(three) - player:hud_remove(four) - end) -end - - --Menu fishing configuration -fishing_setting.func.on_show_settings = function(name) +fishing_setting.func.on_show_settings = function(player_name) if not fishing_setting.tmp_setting then fishing_setting.tmp_setting = {} fishing_setting.func.set_settings(fishing_setting.tmp_setting, fishing_setting.settings) end - local formspec = "size[11,9]label[4,0;FISHING CONFIGURATION]".. + local formspec = "size[11,9]bgcolor[#99a8ba;]label[4,0;FISHING CONFIGURATION]".. --Chance fish "label[1.6,0.5;Chance fish]".. "button[0,1;1,1;cfish;-1]".. @@ -195,25 +152,23 @@ fishing_setting.func.on_show_settings = function(name) "label[2.1,4.2;"..tostring(fishing_setting.tmp_setting["tresor_chance"]).."]".. "button[2.7,4;1,1;ctresor;+10]".. "button[3.7,4;1,1;ctresor;+1]".. - --Bobber view range - "label[7.2,0.5;Bobber view range]".. - "button[7,1;1,1;bvrange;-1]".. - "label[8.1,1.2;"..tostring(fishing_setting.tmp_setting["bobber_view_range"]).."]".. - "button[8.7,1;1,1;bvrange;+1]".. --Chance worm - "label[7.5,2;Chance worm]".. - "button[6,2.5;1,1;cworm;-1]".. - "button[7,2.5;1,1;cworm;-10]".. - "label[8.1,2.7;"..tostring(fishing_setting.tmp_setting["worm_chance"]).."]".. - "button[8.7,2.5;1,1;cworm;+10]".. - "button[9.7,2.5;1,1;cworm;+1]".. - --Timer tresor - "label[7.2,3.5;Timer tresor (in sec)]".. - "button[6,4.;1,1;ttresor;-60]".. - "button[7,4;1,1;ttresor;-600]".. - "label[7.9,4.2;"..tostring(fishing_setting.tmp_setting["tresor_timer"]).."]".. - "button[8.7,4;1,1;ttresor;+600]".. - "button[9.7,4;1,1;ttresor;+60]".. + "label[7.5,0.5;Chance worm]".. + "button[6,1;1,1;cworm;-1]".. + "button[7,1;1,1;cworm;-10]".. + "label[8.1,1.2;"..tostring(fishing_setting.tmp_setting["worm_chance"]).."]".. + "button[8.7,1;1,1;cworm;+10]".. + "button[9.7,1;1,1;cworm;+1]".. + --Chance escape + "label[7.2,2;Chance escape]".. + "button[7,2.5;1,1;cescape;-1]".. + "label[8.1,2.7;"..tostring(fishing_setting.tmp_setting["escape_chance"]).."]".. + "button[8.7,2.5;1,1;cescape;+1]".. + --Bobber view range + "label[7.2,3.5;Bobber view range]".. + "button[7,4;1,1;bvrange;-1]".. + "label[8.1,4.2;"..tostring(fishing_setting.tmp_setting["bobber_view_range"]).."]".. + "button[8.7,4;1,1;bvrange;+1]".. --messages display "label[0,5.7;Display messages in chat]".. "button[3.7,5.5;1,1;dmessages;"..tostring(fishing_setting.tmp_setting["message"]).."]".. @@ -223,9 +178,9 @@ fishing_setting.func.on_show_settings = function(name) --wearout "label[0,7.3;Poles Wear]".. "button[3.7,7.1;1,1;wearout;"..tostring(fishing_setting.tmp_setting["wear_out"]).."]".. - --TRESOR_RANDOM_ENABLE - "label[6,5.7;Random tresor enable]".. - "button[9.7,5.5;1,1;tresorenable;"..tostring(fishing_setting.tmp_setting["tresor_random_enable"]).."]".. + --TRESOR_ENABLE + "label[6,5.7;Tresor enable]".. + "button[9.7,5.5;1,1;tresorenable;"..tostring(fishing_setting.tmp_setting["tresor_enable"]).."]".. --NEW_WORM_SOURCE "label[6,6.5;New worm source]".. "button[9.7,6.3;1,1;newworm;"..tostring(fishing_setting.tmp_setting["new_worm_source"]).."]".. @@ -235,7 +190,7 @@ fishing_setting.func.on_show_settings = function(name) "button_exit[0.5,8.2;1.5,1;save;Abort]".. "button_exit[9,8.2;1.5,1;save;Ok]" - minetest.show_formspec( name, "fishing:settings", formspec) + minetest.show_formspec(player_name, "fishing:settings", formspec) end @@ -246,17 +201,13 @@ local inc = function(value, field, min, max) elseif field == "+10" then v = value + 10 elseif field == "+60" then - v = value + 60 - elseif field == "+600" then - v = value + 600 + v = value + 60 elseif field == "-1" then v = value - 1 elseif field == "-10" then v = value - 10 elseif field == "-60" then v = value - 60 - elseif field == "-600" then - v = value - 600 else -- useless, prevent crash return value end @@ -286,9 +237,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) local name = player:get_player_name() if not name then return end if fields["save"] == "Ok" then - print("ok") - fishing_setting.func.set_settings(fishing_setting.settings, fishing_setting.tmp_setting) - fishing_setting.func.save() + fishing_setting.func.set_settings(fishing_setting.settings, fishing_setting.tmp_setting) + fishing_setting.func.save() + fishing_setting.tmp_setting = nil return elseif fields["quit"] or fields["abort"] then fishing_setting.tmp_setting = nil @@ -303,8 +254,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) fishing_setting.tmp_setting["bobber_view_range"] = inc(fishing_setting.tmp_setting["bobber_view_range"], fields["bvrange"], 4, 20) elseif fields["cworm"] then fishing_setting.tmp_setting["worm_chance"] = inc(fishing_setting.tmp_setting["worm_chance"], fields["cworm"], 1, 100) - elseif fields["ttresor"] then - fishing_setting.tmp_setting["tresor_timer"] = inc(fishing_setting.tmp_setting["tresor_timer"], fields["ttresor"], 1800, 36000) + elseif fields["cescape"] then + fishing_setting.tmp_setting["escape_chance"] = inc(fishing_setting.tmp_setting["escape_chance"], fields["cescape"], 1, 30) elseif fields["dmessages"] then fishing_setting.tmp_setting["message"] = bool(fields["dmessages"]) elseif fields["poledeco"] then @@ -312,7 +263,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) elseif fields["wearout"] then fishing_setting.tmp_setting["wear_out"] = bool(fields["wearout"]) elseif fields["tresorenable"] then - fishing_setting.tmp_setting["tresor_random_enable"] = bool(fields["tresorenable"]) + fishing_setting.tmp_setting["tresor_enable"] = bool(fields["tresorenable"]) elseif fields["newworm"] then fishing_setting.tmp_setting["new_worm_source"] = bool(fields["newworm"]) elseif fields["wormmob"] then @@ -325,3 +276,92 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end end) +--function load settings from file +function fishing_setting.func.load_trophies() + local file = io.open(fishing_setting.file_trophies, "r") + fishing_setting.trophies = {} + if file then + fishing_setting.trophies = minetest.deserialize(file:read("*all")) + file:close() + if fishing_setting.trophies and type(fishing_setting.trophies) ~= "table" then + fishing_setting.trophies = {} + end + end +end + + + +function fishing_setting.func.save_trophies() + local input = io.open(fishing_setting.file_trophies, "w") + if input then + input:write(minetest.serialize(fishing_setting.trophies)) + input:close() + else + minetest.log("action","Open failed (mode:w) of " .. fishing_setting.file_trophies) + end +end + +minetest.register_on_shutdown(function() + minetest.log("action", "[fishing] Server shuts down. saving trophies table") + fishing_setting.func.save_trophies() +end) + +minetest.register_on_joinplayer(function(player) + local playername = player:get_player_name() + if fishing_setting.trophies[playername] == nil then + fishing_setting.trophies[playername] = { ["fish"] = 0,["shark"] = 0, ["pike"] = 0, ["clownfish"]= 0, ["bluefish"] = 0 } + end +end) + + +function fishing_setting.func.add_to_trophies(player, fish) + local player_name = player:get_player_name() + if not player_name then return end + if fish == "fish" or fish == "shark" or fish == "pike" or fish == "clownfish" or fish == "bluefish" then + fishing_setting.trophies[player_name][fish] = fishing_setting.trophies[player_name][fish] + 1 + + if fishing_setting.trophies[player_name][fish]%100 == 0 then + minetest.chat_send_player(player_name, fishing_setting.func.S("You win a new trophie, you have catched %s " .. fish.."."):format(fishing_setting.trophies[player_name][fish])) + 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 +end + + + + +if (minetest.get_modpath("unified_inventory")) then + unified_inventory.register_button("menu_fishing", { + type = "image", + image = "fishing_fish.png", + tooltip = "fishing menu configuration", + action = function(player) + local player_name = player:get_player_name() + if not player_name then return end + if minetest.check_player_privs(player_name, {server=true}) then + fishing_setting.func.on_show_settings(player_name) + else + minetest.chat_send_player(player_name, fishing_setting.func.S("You don't have the server priviledge!")) + + end + + end, + }) +end + +minetest.register_chatcommand("fishing_config", { + params = "", + description = "Display fishing configuration menu (admin only)", + privs = {server=true}, + func = function(player_name, param) + if not player_name then return end + fishing_setting.func.on_show_settings(player_name) + end +}) + diff --git a/init.lua b/init.lua index 5760b4f..78f41eb 100644 --- a/init.lua +++ b/init.lua @@ -1,10 +1,26 @@ -print("loading [fishing] mod") +----------------------------------------------------------------------------------------------- +local title = "Fishing - Crabman77's version" +local version = "0.0.1" +local mname = "fishing" +----------------------------------------------------------------------------------------------- +-- original by wulfsdad (http://forum.minetest.net/viewtopic.php?id=4375) +-- rewrited by Mossmanikin (https://forum.minetest.net/viewtopic.php?id=6480) +-- this version rewrited by Crabman77 +-- License (code & textures): WTFPL +-- Contains code from: animal_clownfish, animal_fish_blue_white, fishing (original), stoneage +-- Looked at code from: default, farming +-- Dependencies: default +-- Supports: animal_clownfish, animal_fish_blue_white, animal_rat, mobs +----------------------------------------------------------------------------------------------- + +minetest.log("action","[mod fishing] Loading...") local path = minetest.get_modpath("fishing").."/" fishing_setting = {} fishing_setting.func = {} fishing_setting.is_creative_mode = minetest.setting_getbool("creative_mode") -fishing_setting.file = minetest.get_worldpath() .. "/fishing_config.txt" +fishing_setting.file_settings = minetest.get_worldpath() .. "/fishing_config.txt" +fishing_setting.file_trophies = minetest.get_worldpath() .. "/fishing_trophies.txt" fishing_setting.settings = {} --for random object @@ -12,6 +28,7 @@ random_objects = {} fishing_setting.baits = {} fishing_setting.hungry = {} fishing_setting.prizes = {} +fishing_setting.trophies = {} if (minetest.get_modpath("intllib")) then dofile(minetest.get_modpath("intllib").."/intllib.lua") @@ -20,7 +37,6 @@ else fishing_setting.func.S = function ( s ) return s end end - dofile(path .."settings.txt") dofile(path .."functions.lua") @@ -35,48 +51,28 @@ fishing_setting.settings["bobber_view_range"] = BOBBER_VIEW_RANGE fishing_setting.settings["fish_chance"] = FISH_CHANCE fishing_setting.settings["shark_chance"] = SHARK_CHANCE fishing_setting.settings["tresor_chance"] = TRESOR_CHANCE -fishing_setting.settings["tresor_timer"] = TRESOR_TIMER -fishing_setting.settings["tresor_random_enable"] = TRESOR_RANDOM_ENABLE - +fishing_setting.settings["tresor_enable"] = TRESOR_RANDOM_ENABLE +fishing_setting.settings["escape_chance"] = ESCAPE_CHANCE -- load config file if exist in worldpath fishing_setting.func.load() - +dofile(path .."worms.lua") dofile(path .."crafting.lua") dofile(path .."baits.lua") dofile(path .."prizes.lua") dofile(path .."baitball.lua") dofile(path .."bobber.lua") ---dofile(path .."bobber_shark.lua") +dofile(path .."bobber_shark.lua") dofile(path .."fishes.lua") dofile(path .."trophies.lua") dofile(path .."poles.lua") -dofile(path .."chatcommands.lua") +--dofile(path .."material.lua") --random hungry bait fishing_setting.func.hungry_random() +--load table catched fish by players +fishing_setting.func.load_trophies() --- timer -fishing_setting.timer = fishing_setting.settings["tresor_timer"] -minetest.register_globalstep(function(dtime) - if fishing_setting.enable == false then return end - fishing_setting.timer = fishing_setting.timer - dtime --- if fishing.new_object then - -- new object is item, time to catch is timer - -- fishing_setting.timer = fishing_setting.settings["tresor_timer"] --- end --- if timer == 300 then - --you have 5min for catch item --- end - if fishing_setting.timer < 0 then - for _, player in ipairs(minetest.get_connected_players()) do - local name = player:get_player_name() - --FIXME display message - end - --set random object - fishing_setting.timer = fishing_setting.settings["tresor_timer"] - end -end) - - -print("loaded [fishing] mod") +----------------------------------------------------------------------------------------------- +minetest.log("action", "[Mod] "..title.." ["..version.."] ["..mname.."] Loaded...") +----------------------------------------------------------------------------------------------- diff --git a/locale/de.txt b/locale/de.txt index 0e1ea57..926a6e6 100644 --- a/locale/de.txt +++ b/locale/de.txt @@ -1,56 +1,87 @@ -# Translation by Xanthin +# Translation original by Xanthin +# adapted for new fishing version by crabman77 ### bobber.lua ### +You didn't catch anything. = Du hast nichts gefangen. +The bait is still there. = +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 Blue white fish. = Du hast einen blau-weissen Fisch gefangen. +You caught a Bluefish. = Du hast einen blau-weissen Fisch gefangen. 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. You caught a Green Kelp. = Du hast etwas gruenen Kelp gefangen. You caught a String. = Du hast eine Schnur gefangen. -You caught an old Fishing Pole. = Du hast eine alte Angelrute gefangen. -You caught some very old Boots. = Du hast ein Paar sehr alte Schuhe gefangen. -You caught a Waterlily. = Du hast eine Seerose gefangen. -You didn't catch anything. = Du hast nichts gefangen. -The bait is still there. = Der Koeder ist noch vorhanden. -Your fish escaped. = Dein Fisch ist entkommen. ### bobber_shark.lua ### You caught a small Shark. = Du hast einen kleinen Hai gefangen. You caught a Northern Pike. = Du hast einen Hecht gefangen. -You didn't catch any fish. = Du hast keinen Fisch gefangen. +You caught an old Fishing Pole. = Du hast eine alte Angelrute gefangen. +You caught some very old Boots. = Du hast ein Paar sehr alte Schuhe gefangen. +You caught a Gold Coin. = +You caught a very old Helmet. = +You caught a very old Shield. = +You caught a very old Sword. = +You caught a mese block. = +You caught a Nyan Cat. = +You caught a Diamond Block. = +Haha, Fishing is prohibited outside water! = + + + ### crafting.lua ### +Bait Ball = +Shark Bait Ball = + + ### fishes.lua ### Fish = Fisch Roasted Fish = Gebratener Fisch Sushi (Hoso Maki) = Sushi (Hoso Maki) +Clownfish = Clownfisch +Bluefish = blau-weisse Fisch Shark = Hai Roasted Shark = Gebratener Hai Northern Pike = Hecht Roasted Northern Pike = Gebratener Hecht -### init.lua ### + +### functions.lua ### +You don't have the server priviledge! = +You win a new trophie, you have catched %s fish. = +You win a new trophie, you have catched %s shark. = +You win a new trophie, you have catched %s pike. = +You win a new trophie, you have catched %s clownfish. = +You win a new trophie, you have catched %s bluefish. = + + +### material.lua ### +Show information about hunger fish = + + +### poles.lua ### Fishing Pole = Angelrute -Dirt = Erde -Wooden Hoe = Holzhacke -Stone Hoe = Steinhacke -Steel Hoe = Stahlhacke -Bronze Hoe = Bronzehacke +Perfect Fishing Pole = + ### trophies.lua ### Fish Trophy = Fisch-Trophaee Northern Pike Trophy = Hecht-Trophaee Shark Trophy = Hai-Trophaee Clownfish Trophy = Clownfisch-Trophaee -Blue white fish Trophy = Blau-weisser-Fisch-Trophaee -Trophy = Trophaee +Bluefish Trophy = Blau-weisser-Fisch-Trophaee This Huge Fish was caught by the Famous Angler %s ! = Dieser riesige Fisch wurde vom beruehmten Angler %s gefangen! This Huge Northern Pike was caught by the Famous Angler %s ! = Dieser riesige Hecht wurde vom beruehmten Angler %s gefangen! This Huge Shark was caught by the Famous Angler %s ! = Dieser riesige Hai wurde vom beruehmten Angler %s gefangen! This Huge Clownfish was caught by the Famous Angler %s ! = Dieser riesige Clownfisch wurde vom beruehmten Angler %s gefangen! -This Huge Blue white fish was caught by the Famous Angler %s ! = Dieser riesige blau-weisse Fisch wurde vom beruehmten Angler %s gefangen! +This Huge Bluefish was caught by the Famous Angler %s ! = Dieser riesige blau-weisse Fisch wurde vom beruehmten Angler %s gefangen! ### worms.lua ### Worm = Wurm +Dirt = Erde +Wooden Hoe = Holzhacke +Stone Hoe = Steinhacke +Steel Hoe = Stahlhacke +Bronze Hoe = Bronzehacke diff --git a/locale/fr.txt b/locale/fr.txt new file mode 100644 index 0000000..df70fbe --- /dev/null +++ b/locale/fr.txt @@ -0,0 +1,85 @@ + +### bobber.lua ### +You didn't catch anything. = Vous n'avez rien attrape. +The bait is still there. = L'appat est toujours la. +Your fish escaped. = Le poisson s'est decroche. +You caught a Fish. = Vous avez attrape un poisson. +You caught a Clownfish. = Vous avez attrape un poisson clown. +You caught a Bluefish. = Vous avez attrape un poisson bleu. +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. +You caught a String. = Vous avez attrape une ficelle. + +### bobber_shark.lua ### +You caught a small Shark. = Vous avez attrape un requin +You caught a Northern Pike. = Vous avez attrape un brochet. +You caught an old Fishing Pole. = Vous avez attrape une vielle canne a peche. +You caught some very old Boots. = Vous avez attrape de tres vieilles bottes. +You caught a Gold Coin. = Vous avez attrape une pice en or. +You caught a very old Helmet. = Vous avez attrape un casque tres vieux. +You caught a very old Shield. = Vous avez attrape un bouclier tres vieux. +You caught a very old Sword. = Vous avez attrape une epee tres ancienne. +You caught a mese block. = Vous avez attrape un bloc de mese. +You caught a Nyan Cat. = Vous avez attrape un Nyan Cat. +You caught a Diamond Block. = Vous avez attrape block de diamant. +Haha, Fishing is prohibited outside water! = Haha, pecher est interdit en dehors de l'eau! + + + + +### crafting.lua ### +Bait Ball = Amorce +Shark Bait Ball = Amorce a carnassier + + +### fishes.lua ### +Fish = Poisson +Roasted Fish = Poisson grille +Sushi (Hoso Maki) = Sushi (Hoso Maki) +Clownfish = Poisson clown +Bluefish = Poisson bleu +Shark = Requin +Roasted Shark = Requin grille +Northern Pike = Brochet +Roasted Northern Pike = Brochet grille + + +### functions.lua ### +You don't have the server priviledge! = Vous n'avez pas les privilèges serveur! +You win a new trophie, you have catched %s fish. = Vous gagnez un trophee, vous avez attrape %s poissons. +You win a new trophie, you have catched %s shark. = Vous gagnez un trophee, vous avez attrape %s requins. +You win a new trophie, you have catched %s pike. = Vous gagnez un trophee, vous avez attrape %s brochets. +You win a new trophie, you have catched %s clownfish. = Vous gagnez un trophee, vous avez attrape %s poissons clown. +You win a new trophie, you have catched %s bluefish. = Vous gagnez un trophee, vous avez attrape %s poissons bleu. + +### material.lua ### +View information about hunger fish = Afficher les informations sur la faim des poissons + + +### poles.lua ### +Fishing Pole = Canne a peche +Perfect Fishing Pole = Canne a peche parfaite + + +### trophies.lua ### +Fish Trophy = Trophee poisson +Northern Pike Trophy = Trophee brochet +Shark Trophy = Trophee requin +Clownfish Trophy = Trophee poisson clown +Bluefish Trophy = Trophee poisson bleu +This Huge Fish was caught by the Famous Angler %s ! = +This Huge Northern Pike was caught by the Famous Angler %s ! = +This Huge Shark was caught by the Famous Angler %s ! = +This Huge Clownfish was caught by the Famous Angler %s ! = +This Huge Bluefish was caught by the Famous Angler %s ! = + +### worms.lua ### +Worm = ver +Dirt = terre +Wooden Hoe = Hoe en bois +Stone Hoe = Hoe en pierre +Steel Hoe = Hoe en fer +Bronze Hoe = Hoe en bronze + diff --git a/locale/template.txt b/locale/template.txt index 3ed36dc..6454b47 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -1,56 +1,84 @@ -# Template ### bobber.lua ### +You didn't catch anything. = +The bait is still there. = +Your fish escaped. = You caught a Fish. = You caught a Clownfish. = -You caught a Blue white fish. = +You caught a Bluefish. = You caught a Twig. = You caught a Rat. = You caught some Seaweed. = You caught a Green Kelp. = You caught a String. = -You caught an old Fishing Pole. = -You caught some very old Boots. = -You caught a Waterlily. = -You didn't catch anything. = -The bait is still there. = -Your fish escaped. = ### bobber_shark.lua ### -You caught small Shark. = +You caught a small Shark. = You caught a Northern Pike. = -You didn't catch any fish. = +You caught an old Fishing Pole. = +You caught some very old Boots. = +You caught a Gold Coin. = +You caught a very old Helmet. = +You caught a very old Shield. = +You caught a very old Sword. = +You caught a mese block. = +You caught a Nyan Cat. = +You caught a Diamond Block. = +Haha, Fishing is prohibited outside water! = + ### crafting.lua ### +Bait Ball = +Shark Bait Ball = + + ### fishes.lua ### -Fish = +Fish = Roasted Fish = Sushi (Hoso Maki) = +Clownfish = +Bluefish = Shark = Roasted Shark = Northern Pike = Roasted Northern Pike = -### init.lua ### -Fishing Pole = -Dirt = -Wooden Hoe = -Stone Hoe = -Steel Hoe = -Bronze Hoe = + +### functions.lua ### +You don't have the server priviledge! = +You win a new trophie, you have catched %s fish. = +You win a new trophie, you have catched %s shark. = +You win a new trophie, you have catched %s pike. = +You win a new trophie, you have catched %s clownfish. = +You win a new trophie, you have catched %s bluefish. = + + +### material.lua ### +Show information about hunger fish = + + +### poles.lua ### +Fishing Pole = +Perfect Fishing Pole = + ### trophies.lua ### -Fish Trophy = -Northern Pike Trophy = -Shark Trophy = -Clownfish Trophy = -Blue white fish Trophy = -Trophy = +Fish Trophy = +Northern Pike Trophy = +Shark Trophy = +Clownfish Trophy = +Bluefish Trophy = This Huge Fish was caught by the Famous Angler %s ! = This Huge Northern Pike was caught by the Famous Angler %s ! = This Huge Shark was caught by the Famous Angler %s ! = This Huge Clownfish was caught by the Famous Angler %s ! = -This Huge Blue white fish was caught by the Famous Angler %s ! = +This Huge Bluefish was caught by the Famous Angler %s ! = ### worms.lua ### -Worm = +Worm = +Dirt = +Wooden Hoe = +Stone Hoe = +Steel Hoe = +Bronze Hoe = + diff --git a/material.lua b/material.lua new file mode 100644 index 0000000..6951b18 --- /dev/null +++ b/material.lua @@ -0,0 +1,35 @@ + + +-- useless or useful ??? +minetest.register_node("fishing:material_info", { + description = fishing_setting.func.S("Show information about hunger fish"), + name = "Fishing Info Center", + tiles = {"default_wood.png", "default_wood.png", "default_wood.png", + "default_wood.png", "default_wood.png", "default_wood.png"}, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + paramtype2 = "facedir", + legacy_facedir_simple = true, + is_ground_content = false, + sounds = default.node_sound_wood_defaults(), + + + on_rightclick = function(pos, _, clicker) + local formspec = "size[6,8]label[1.7,0;Fishing Info Center]" + local y = 1 + for i, a in pairs(fishing_setting.baits) do + formspec = formspec .."item_image_button[1,"..tostring(y)..";1,1;"..tostring(i)..";"..tostring(i)..";]".. + --formspec = formspec .."image[1,"..tostring(y)..";1,1;"..tostring(a["texture"]).."]".. + "label[2.2,"..tostring(y+0.2)..";Chance to fish :"..tostring(a["hungry"]).."%]" + y = y+1 + end + minetest.show_formspec(clicker:get_player_name(),"fishing:material_info", formspec) + end + +}) + + +minetest.register_craft({ + output = 'fishing:material_info', + type = 'shapeless', + recipe = { 'default:steel_ingot', 'default:steel_ingot' }, +}) diff --git a/poles.lua b/poles.lua index 8a84230..1200967 100644 --- a/poles.lua +++ b/poles.lua @@ -21,12 +21,11 @@ for _,pole in pairs(fishing_setting.poles) do wield_image = "fishing_pole_".. pole.name ..".png^[transformFXR270", stack_max = 1, liquids_pointable = true, - + on_use = function (itemstack, user, pointed_thing) if pointed_thing and pointed_thing.under then local pt = pointed_thing local node = minetest.get_node(pt.under) - --if node.name ~= "default:water_source" and node.name ~= "noairblocks:water_sourcex" and node.name ~= "default:river_water_source" then return nil end if not node or string.find(node.name, "water_source") == nil then return nil end local player = user:get_player_name() local inv = user:get_inventory() @@ -38,10 +37,10 @@ for _,pole in pairs(fishing_setting.poles) do local objs = minetest.get_objects_inside_radius(pt.under, 3) for m, obj in pairs(objs) do if obj:get_luaentity() ~= nil and string.find(obj:get_luaentity().name, "fishing:bobber") ~= nil then - bobbers[m] = obj + bobbers[m] = obj end end - + local nodes = {} local i = 1 for _,k in pairs({ 1, 0, -1}) do @@ -68,7 +67,7 @@ for _,pole in pairs(fishing_setting.poles) do end --if water == -3 nodes if #nodes < 2 then - minetest.chat_send_player(player, "You don't fishing in a bottle!!! ") + if fishing_setting.settings["message"] == true then minetest.chat_send_player(player, "You don't fishing in a bottle!!! ") end return nil end local new_pos = nodes[math.random(1, #nodes)] @@ -86,16 +85,17 @@ for _,pole in pairs(fishing_setting.poles) do minetest.sound_play("fishing_bobber2", {pos = new_pos, gain = 0.5}) if fishing_setting.settings["wear_out"] == true and not fishing_setting.is_creative_mode then - return rod_wear(itemstack, user, pointed_thing, pole.max_use) + return rod_wear(itemstack, user, pointed_thing, pole.max_use) else return {name="fishing:pole_".. pole.name, count=1, wear=0, metadata=""} end end return nil end, - - + + on_place = function(itemstack, placer, pointed_thing) + if fishing_setting.settings["simple_deco_fishing_pole"] == false then return end local pt = pointed_thing local pt_under_name = minetest.get_node(pt.under).name if pt_under_name ~= "default:water_source" and pt_under_name ~= "default:water_flowing" then @@ -156,4 +156,3 @@ for _,pole in pairs(fishing_setting.poles) do }) end - diff --git a/prizes.lua b/prizes.lua index 58c97c4..e511d89 100644 --- a/prizes.lua +++ b/prizes.lua @@ -1,28 +1,46 @@ -minetest.register_alias("flowers_plus:seaweed", "flowers:seaweed") -- exception fishing_setting.prizes["fish"] = { - {"fishing", "fish_raw", 0, "a Fish."} + {"fishing", "fish", 0, "a Fish."}, + {"fishing", "clownfish", 0, "a Clownfish."}, + {"fishing", "bluefish", 0, "a Bluefish."} +} + +fishing_setting.prizes["shark"] = { + {"fishing", "shark", 0, "a small Shark."}, + {"fishing", "pike", 0, "a Northern Pike."} } -- Here's what you can prizes -fishing_setting.prizes["plants"] = { +local plants = { -- MoD iTeM WeaR MeSSaGe ("You caught "..) {"default", "stick", 0, "a Twig."}, {"mobs", "rat", 0, "a Rat."}, - {"flowers_plus", "seaweed", 0, "some Seaweed."}, + {"flowers", "seaweed", 0, "some Seaweed."}, {"seaplants", "kelpgreen", 0, "a Green Kelp."}, {"farming", "string", 0, "a String."}, {"trunks", "twig_1", 0, "a Twig."} } +fishing_setting.prizes["plants"] = fishing_setting.func.ignore_mod(plants) - -fishing_setting.prizes["stuff"] = { - {"fishing", "pole_wood", "randomtools", "an old Fishing Pole."}, - {"3d_armor", "boots_wood", "random", "some very old Boots."} +local stuff = { + {"fishing", "pole_wood", "randomtools", "an old Fishing Pole."}, + {"3d_armor", "boots_wood", "random", "some very old Boots."}, + {"maptools", "gold_coin", 0, "a Gold Coin."}, + {"3d_armor", "helmet_diamond", "random", "a very old Helmet."}, + {"shields", "shield_enhanced_cactus", "random", "a very old Shield."}, + {"default", "sword_bronze", "random", "a very old Sword."}, + {"default", "sword_mese", "random", "a very old Sword."}, + {"default", "sword_nyan", "random", "a very old Sword."} } +fishing_setting.prizes["stuff"] = fishing_setting.func.ignore_mod(stuff) -fishing_setting.prizes["tresor"] = {"default", "mese", 0, "a mese block."} +local tresor = { + {"default", "mese", 0, "a mese block."}, + {"default", "nyancat", 0, "a Nyan Cat."}, + {"default", "diamondblock", 0, "a Diamond Block."}, +} +fishing_setting.prizes["tresor"] = fishing_setting.func.ignore_mod(tresor) diff --git a/random_object.lua b/random_object.lua deleted file mode 100644 index beb51a2..0000000 --- a/random_object.lua +++ /dev/null @@ -1,3 +0,0 @@ - - -random_objects = {} diff --git a/settings.txt b/settings.txt index aa37b58..17f246c 100644 --- a/settings.txt +++ b/settings.txt @@ -8,5 +8,5 @@ WORM_CHANCE = 66 FISH_CHANCE = 60 SHARK_CHANCE = 50 TRESOR_CHANCE = 5 -TRESOR_TIMER = 3600 TRESOR_RANDOM_ENABLE = true +ESCAPE_CHANCE = 5 diff --git a/textures/alternates/fishing_bobber_bottom.png b/textures/alternates/fishing_bobber_bottom.png deleted file mode 100644 index e3404aab0062208b82097cd3f24f7bf7b2df6f8e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 207 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0figD*u3fvW60T^vI!{F4(TShsLCK0iPI|M9lYZM;i<9%y9#uOGLEboFyt=akR{09m*}b^rhX diff --git a/textures/alternates/fishing_bobber_top.png b/textures/alternates/fishing_bobber_top.png deleted file mode 100644 index b4b4a4ec99454b65b35cf36af791f06ce4996e87..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 193 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L0m@TF)WP?fEx zi(`m|e{zBZ>lV(&qdc4bZ%ka2%bd9`S>XTu(+Zr&6wEw&RG1y464y0se3{K~G;V>0 iK!lvI6;>1s;*b z3=G^rh1>#+YnAtw0tKZ?Tq8N0kgxl*{3J1lgxAI=rpmYd{nfnxtTeF&rNxCGQ-VxOI16rzf|bGVbUDS nz*U;W#5eu5gvLc4BM}C(vj000McNliru-v$v9BPpxkSrY&N0pUqR zK~y-))sxL@6JZd>fA8+QX7g#mm=dA~5xsfv(xQm{5HCV5{sVeY)QfoZAc`09R`Af~ z;6EVV#e<|&6se`C2qGd@3^eJNY1U-3Np|1ykPwhsJ&FUvzytFP&pb2m--r4gc;|FV z*8CO#uB$9PvH zyvMebklt@o*q0!ov-E<9uWME6zMSuh!nq}J0Mw(~V=5-w-FGiO>y4(tjm0>W zPmoJzX>=O2I*ME_PY~0ruhjUqS|y4Mqse4=_j%J%{ptBIsCaha4z|{G{U+tP8OqO|;wu%EmPPA<0;_Q17{!ZMi6v6IZakhIVfxw)yvhfbKUHi1 ztG|h+j2<|M6LbG+o15Cp;j?Ern(4Rd^8G1=?}?-LU`&LvY?M;F5|}8W9d08>M3@I_ z`sTb$U7vO0&45;89WfCi24f5&GE5VN^g3=G`P)sICa5SLf}ma;$_~mr z%u&IE4DlDvDeTs4)jFlA%bK|~P0}PaU0pm)L|ffy@A2jHJ}lgp-_1@;M_xqk^J0R$gQ97-tkBot=*Qe0Wo1rPwu{~0O) zoVj&REcf;@vb0Rjwl-V{gwOn@000**siLxb7tY|pt$oj*o(sTo;KAED00000NkvXX Hu0mjf^S}OH literal 0 HcmV?d00001 diff --git a/textures/animal_fish_blue_white_fish_blue_white_item.png b/textures/fishing_bluefish.png old mode 100644 new mode 100755 similarity index 100% rename from textures/animal_fish_blue_white_fish_blue_white_item.png rename to textures/fishing_bluefish.png diff --git a/textures/fishing_bobber.png b/textures/fishing_bobber.png old mode 100644 new mode 100755 diff --git a/textures/fishing_bobber_bottom.png b/textures/fishing_bobber_bottom.png old mode 100644 new mode 100755 diff --git a/textures/fishing_bobber_feather_1.png b/textures/fishing_bobber_feather_1.png old mode 100644 new mode 100755 diff --git a/textures/alternates/fishing_bobber.png b/textures/fishing_bobber_shark.png old mode 100644 new mode 100755 similarity index 100% rename from textures/alternates/fishing_bobber.png rename to textures/fishing_bobber_shark.png diff --git a/textures/fishing_bobber_top.png b/textures/fishing_bobber_top.png old mode 100644 new mode 100755 diff --git a/textures/animal_clownfish_clownfish_item.png b/textures/fishing_clownfish.png old mode 100644 new mode 100755 similarity index 100% rename from textures/animal_clownfish_clownfish_item.png rename to textures/fishing_clownfish.png diff --git a/textures/fishing_deco_pike.png b/textures/fishing_deco_pike.png old mode 100644 new mode 100755 diff --git a/textures/fishing_fish.png b/textures/fishing_fish.png old mode 100644 new mode 100755 diff --git a/textures/fishing_fish_cooked.png b/textures/fishing_fish_cooked.png old mode 100644 new mode 100755 diff --git a/textures/fishing_particle_baitball.png b/textures/fishing_particle_baitball.png old mode 100644 new mode 100755 diff --git a/textures/fishing_particle_baitball_shark.png b/textures/fishing_particle_baitball_shark.png new file mode 100755 index 0000000000000000000000000000000000000000..0224abe7f70c72d27e0e9bd794519fe9c8aba7fd GIT binary patch literal 223 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqY)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP~n;^f8Ny{<)t3aU~PZ!4!iOb0e2lyibD*ktG`u|`5 z)W3e6V;wq@e|*{-fgo}16;ZZh`&RZ8usRA}{=a_eu0sV$XS3KqpnF0<$2*{ukAW-? z5Zn#xmFRQW$aIXaZrR}td9G^8ZCN>eDG5Mu?72U~11IIE$dE2CpuG&9u6{1-oD!M< Difc;l literal 0 HcmV?d00001 diff --git a/textures/fishing_pike.png b/textures/fishing_pike.png old mode 100644 new mode 100755 diff --git a/textures/fishing_pike_cooked.png b/textures/fishing_pike_cooked.png old mode 100644 new mode 100755 diff --git a/textures/fishing_pole_perfect.png b/textures/fishing_pole_perfect.png old mode 100644 new mode 100755 diff --git a/textures/fishing_pole_perfect_back.png b/textures/fishing_pole_perfect_back.png old mode 100644 new mode 100755 diff --git a/textures/fishing_pole_perfect_bottom.png b/textures/fishing_pole_perfect_bottom.png old mode 100644 new mode 100755 diff --git a/textures/fishing_pole_perfect_front.png b/textures/fishing_pole_perfect_front.png old mode 100644 new mode 100755 diff --git a/textures/fishing_pole_perfect_simple.png b/textures/fishing_pole_perfect_simple.png old mode 100644 new mode 100755 diff --git a/textures/fishing_pole_perfect_top.png b/textures/fishing_pole_perfect_top.png old mode 100644 new mode 100755 diff --git a/textures/fishing_pole_wood.png b/textures/fishing_pole_wood.png old mode 100644 new mode 100755 diff --git a/textures/fishing_pole_wood_back.png b/textures/fishing_pole_wood_back.png old mode 100644 new mode 100755 diff --git a/textures/fishing_pole_wood_bottom.png b/textures/fishing_pole_wood_bottom.png old mode 100644 new mode 100755 diff --git a/textures/fishing_pole_wood_deco.png b/textures/fishing_pole_wood_deco.png old mode 100644 new mode 100755 diff --git a/textures/fishing_pole_wood_front.png b/textures/fishing_pole_wood_front.png old mode 100644 new mode 100755 diff --git a/textures/fishing_pole_wood_simple.png b/textures/fishing_pole_wood_simple.png old mode 100644 new mode 100755 diff --git a/textures/fishing_pole_wood_top.png b/textures/fishing_pole_wood_top.png old mode 100644 new mode 100755 diff --git a/textures/fishing_shark.png b/textures/fishing_shark.png old mode 100644 new mode 100755 diff --git a/textures/fishing_shark_cooked.png b/textures/fishing_shark_cooked.png old mode 100644 new mode 100755 diff --git a/textures/fishing_sushi.png b/textures/fishing_sushi.png old mode 100644 new mode 100755 diff --git a/textures/fishing_trophy_label.png b/textures/fishing_trophy_label.png old mode 100644 new mode 100755 diff --git a/textures/not_in_use/fishing_bobber_feather_1.png b/textures/not_in_use/fishing_bobber_feather_1.png deleted file mode 100644 index 9eff3f8d8af519546768d0b635fd5f69f7e4152c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 352 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0figD*u3fvV1Xx;Tbd_$MbwuqvCfB;DoxXZ^bCum2abpZ-A-OW33S@^1_M{XS9U zul=o1{v3`#wkhgWfB82B{>@*n`NdxQh}as*6oJ55+LQMDcei@|r~K;lAM>T(eYhVn zjdzXY6RAZ!9fgf?)B|Hr9q`fuE{rt>n7k%Iaexi?G`#2wli uf4KaVUZ!#K_?LRmIluqk`ob_rig8V3gpSOYxz~YSWAJqKb6Mw<&;$UHE{jwE diff --git a/textures/not_in_use/fishing_bobber_feather_2.png b/textures/not_in_use/fishing_bobber_feather_2.png deleted file mode 100644 index 9f710c32025ea78e96f3b6a13fd8fc5546b4b426..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 363 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0figD*u3fvRqKx;Tbd_`jXt&418Ar1keqN)6?S}R( zd3JfG0-8)*kJlN?KP|L>oiT~!jjLq%_QTT;UD(X?U=2rzP5} zKKVr9Y#wQeP6YBF3^_@p00i_>zopr E0FNJwg#Z8m diff --git a/textures/not_in_use/fishing_bobber_ready.png b/textures/not_in_use/fishing_bobber_ready.png deleted file mode 100644 index 2a37b4e9d3fda27d6a21626451d224ac1967f193..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 222 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L0m@TF)WP*s$t zi(`m|fAWw2|LvKr@))=h58t@5DC5{t!C0A_3MtGDk5m{p#LZw-dFc}5Bg=eZtL&Qo z#v2WXm*!bWI0SMiE!8MGyU@={!Q6C_N~%Ho4U!lvI6;>1s;*b z3=G^rh1>#+YnAtw0tKZ?Tq80C&Kf7io?>upjjiNUl eHW>+TVr1}NdZRn_E6-w}tqh*7elF{r5}E+Lnn|z# diff --git a/textures/old/fishing_bobber_alternate_old.png b/textures/old/fishing_bobber_alternate_old.png deleted file mode 100644 index 5779a71e37217c79e146b5a3e24204f84534a424..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 217 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L0m@TF)WP*td> zi(`m|e{#YBrc;Ma{wE*4ab;1*!%H1{eODLED(U{eBtgX4<6_4eu{;h}wh5~xm-RQ^ zXgDlseE0xE7qg(q^e0kIb4wVETSLMV&hj5|)4aJ;Xto6L`Ty0;0nJQ2>bZyaD*B`wAlAkxwy;=0c8iYNP%Wo}cJ@EEq-_;GyVOaaO6 cmNz^MAIx~=T(XLP0xe?jboFyt=akR{09#5+CjbBd diff --git a/textures/old/fishing_pole_wield.png b/textures/old/fishing_pole_wield.png deleted file mode 100644 index cb0dcc9a6ce1b3023d50e332980a279968add15d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 269 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=G_YAk0{w5SQ7HGG>Qaoge+ytmRt9 z$j8U$lF4?nFOgy6EXQ@u*Le7uComq7Xv(v`=5R!m?S_ePE`#1#7s&>HV@GC=%wyRM zhO;(GC1@P|I6va71Y3hi6OTiGcFjuRdEy=$MQ=KEZ8AEcz|g(pbmpUXHu6A6F?hQA KxvXN2bPDNB8 zb~7$DE-^4L^m3s9009F@L_t(IPsNeTYQjJmg?%cYK!l({i6r$JL%?1}jg#0aQ5R~g zkusD*5yXuseU;*49i5R#H+75~2Zq`F-#O<$lStg-G{>LdH?}v28iNpwB@t|YE(@rJ z4ddAZnTBF8f~}SVk9}eHyO$@>>=sOK1owT3Zt#JuRsh@VFkY?YFn3k*Wps{k!=J-= zaZzo*f+vWzdjyl=9D3P~2h(6FoSl%N+VPQ6^y>wj**9u*hzjkA#x;vT)$4MBbgqO_ zyARVHo#ANbs}s;;aU@uX=+eTJf+^xX5DzBxVZTj~DW1xTUa1J*jmOJbPr_LW{5Qb= lU9COdE)e^lZ;tv0JOH}=l}Vw+Oxyqf002ovPDHLkV1g_Fp_Kpt diff --git a/trophies.lua b/trophies.lua index e69de29..d241763 100644 --- a/trophies.lua +++ b/trophies.lua @@ -0,0 +1,84 @@ +----------------------------------------------------------------------------------------------- +-- Fishing - crabman77's version +-- Rewrited from original Fishing - Mossmanikin's version - Trophies 0.0.2 +-- License (code & textures): WTFPL +-- Contains code from: default +-- Supports: animal_clownfish, animal_fish_blue_white +----------------------------------------------------------------------------------------------- + + +local trophy = { +-- mod item name icon + {"fishing", "fish", "Fish", "fishing_fish.png"}, + {"fishing", "pike", "Northern Pike", "fishing_pike.png"}, + {"fishing", "shark", "Shark", "fishing_shark.png"}, + {"fishing", "clownfish", "Clownfish", "fishing_clownfish.png"}, + {"fishing", "bluefish", "Bluefish", "fishing_bluefish.png"}, +} + +local function has_trophy_privilege(meta, player) + if player:get_player_name() ~= meta:get_string("owner") then + return false + end + return true +end + +for i in pairs(trophy) do + local mod = trophy[i][1] + local item = trophy[i][2] + local name = trophy[i][3] + local icon = trophy[i][4] + minetest.register_node("fishing:trophy_"..item, { + description = fishing_setting.func.S(name.." Trophy"), + inventory_image = "default_chest_top.png^"..icon.."^fishing_trophy_label.png", + drawtype = "nodebox", + tiles = { + "default_chest_top.png", -- top + "default_chest_top.png", -- bottom + "default_chest_top.png", -- right + "default_chest_top.png", -- left + "default_chest_top.png", -- back + "default_chest_top.png^"..icon.."^fishing_trophy_label.png", -- front + }, + paramtype = "light", + paramtype2 = "facedir", + walkable = false, + node_box = { + type = "fixed", + fixed = { + -- { left , bottom , front , right , top , back } + { -1/2 , -1/2 , 7/16 , 1/2 , 1/2 , 1/2 }, + } + }, + selection_box = { + type = "fixed", + fixed = { + { -1/2 , -1/2 , 7/16 , 1/2 , 1/2 , 1/2 }, + } + }, + groups = {choppy=2,oddly_breakable_by_hand=3,flammable=2}, + sounds = default.node_sound_wood_defaults(), + after_place_node = function(pos, placer) + local meta = minetest.get_meta(pos) + meta:set_string("owner", placer:get_player_name() or "") + meta:set_string("infotext", fishing_setting.func.S("This Huge "..name.." was caught by the Famous Angler %s !"):format((placer:get_player_name() or ""))) + end, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("infotext", name) + meta:set_string("owner", "") + end, + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + return has_trophy_privilege(meta, player) + end, + }) + +--[[ + minetest.register_craft({ + type = "shapeless", + output = "fishing:trophy_"..item, + recipe = {mod..":"..item, "default:sign_wall"}, + }) +--]] +end diff --git a/worms.lua b/worms.lua index e69de29..ba6e1a7 100644 --- a/worms.lua +++ b/worms.lua @@ -0,0 +1,245 @@ +----------------------------------------------------------------------------------------------- +-- Fishing - crabman77's version +-- Rewrited from original Fishing - Mossmanikin's version - Worm 0.0.2 +----------------------------------------------------------------------------------------------- +-- License (code & textures): WTFPL +-- Contains code from: fishing (original), mobs +-- Looked at code from: my_mobs +-- Dependencies: default +----------------------------------------------------------------------------------------------- + +----------------------------------------------------------------------------------------------- +-- WORM ITEM +----------------------------------------------------------------------------------------------- +minetest.register_craftitem("fishing:bait_worm", { + description = fishing_setting.func.S("Worm"), + groups = { fishing_bait=1 }, + inventory_image = "fishing_bait_worm.png", + on_use = minetest.item_eat(1), + on_place = function(itemstack, placer, pointed_thing) + local pt = pointed_thing + minetest.add_entity({x=pt.under.x, y=pt.under.y+0.6, z=pt.under.z}, "fishing:bait_worm_entity") + itemstack:take_item() + return itemstack + end, + on_drop = function(itemstack, dropper, pos) + minetest.add_entity({x = pos.x, y = pos.y, z = pos.z}, "fishing:bait_worm_entity") + itemstack:take_item() + return itemstack + end, +}) + +----------------------------------------------------------------------------------------------- +-- WORM MOB +----------------------------------------------------------------------------------------------- +minetest.register_entity("fishing:bait_worm_entity", { + hp_max = 300, + damage_over_time = 1, + collisionbox = {-3/16, -3/16, -3/16, 3/16, 3/16, 3/16}, + visual = "sprite", + visual_size = {x=1/2, y=1/2}, + textures = { "fishing_bait_worm.png", "fishing_bait_worm.png"}, + view_range = 32, + -- Don't punch this poor creature... + on_punch = function(self, puncher) + self.object:remove() + end, + -- ...softly take it into your hand. + on_rightclick = function(self, clicker) + if clicker:is_player() and clicker:get_inventory() then + clicker:get_inventory():add_item("main", "fishing:bait_worm") + self.object:remove() + end + end, + -- AI :D + on_step = function(self, dtime) + local pos = self.object:getpos() + -- despawn when no player in range + local remove_entity = true + for _,player in pairs(minetest.get_connected_players()) do + local p = player:getpos() + 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 + break + end + end + if remove_entity then + self.object:remove() + return + end + local n = minetest.get_node({x=pos.x,y=pos.y-0.3,z=pos.z}) + -- move in world + 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: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)))}) + + 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: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)))}) + 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)))}) + elseif self.object:get_hp() == 0 then + self.object:remove() + end + else -- check if there's dirt anywhere (not finished) + local check_group = minetest.get_item_group + local goal_01 = check_group(minetest.get_node({x = pos.x + 1, y = pos.y-0.4, z = pos.z }).name, "soil") + local goal_02 = check_group(minetest.get_node({x = pos.x, y = pos.y-0.4, z = pos.z + 1}).name, "soil") + local goal_03 = check_group(minetest.get_node({x = pos.x - 1, y = pos.y-0.4, z = pos.z }).name, "soil") + local goal_04 = check_group(minetest.get_node({x = pos.x, y = pos.y-0.4, z = pos.z - 1}).name, "soil") + + local goal_1a = check_group(minetest.get_node({x = pos.x + 1, y = pos.y+0.6, z = pos.z }).name, "soil") + local goal_2a = check_group(minetest.get_node({x = pos.x, y = pos.y+0.6, z = pos.z + 1}).name, "soil") + local goal_3a = check_group(minetest.get_node({x = pos.x - 1, y = pos.y+0.6, z = pos.z }).name, "soil") + 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)))}) + 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}) + 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)))}) + 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}) + 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)))}) + end + end + end + look_whats_up(self) + end, +}) + +-- Bait Worm Entity +minetest.register_craft({ + output = "fishing:bait_worm_entity 8", + recipe = { + {"default:dirt"}, + {"default:dirt"}, + } +}) + +----------------------------------------------------------------------------------------------- +-- GETTING WORMS +----------------------------------------------------------------------------------------------- +-- get worms from digging in dirt: +if fishing_setting.settings["new_worm_source"] == false then + minetest.register_node(":default:dirt", { + description = fishing_setting.func.fishing_setting.func.S("Dirt"), + tiles = {"default_dirt.png"}, + is_ground_content = true, + groups = {crumbly=3}, + sounds = default.node_sound_dirt_defaults(), + after_dig_node = function (pos, oldnode, oldmetadata, digger) + if math.random(1, 100) <= fishing_setting.settings["worm_chance"] then + local tool_in_use = digger:get_wielded_item():get_name() + if tool_in_use == "" or tool_in_use == "default:dirt" then + if fishing_setting.settings["worm_is_mob"] == true then + minetest.add_entity({x = pos.x, y = pos.y+0.4, z = pos.z}, "fishing:bait_worm_entity") + else + local inv = digger:get_inventory() + if inv:room_for_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""}) then + inv:add_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""}) + end + end + end + end + end, + }) + +else + -- get worms from digging with hoes: + -- turns nodes with group soil=1 into soil + local function hoe_on_use(itemstack, user, pointed_thing, uses) + local pt = pointed_thing + -- check if pointing at a node + if not pt or pt.type ~= "node" then + return + end + + local under = minetest.get_node(pt.under) + local p = {x=pt.under.x, y=pt.under.y+1, z=pt.under.z} + local above = minetest.get_node(p) + + -- return if any of the nodes is not registered + if not minetest.registered_nodes[under.name] then + return + end + if not minetest.registered_nodes[above.name] then + return + end + + -- check if the node above the pointed thing is air + if above.name ~= "air" then + return + end + + -- check if pointing at dirt + if minetest.get_item_group(under.name, "soil") ~= 1 then + return + end + + -- turn the node into soil, play sound, get worm and wear out item + minetest.set_node(pt.under, {name="farming:soil"}) + minetest.sound_play("default_dig_crumbly", { + pos = pt.under, + gain = 0.5, + }) + + if math.random(1, 100) < fishing_setting.settings["worm_chance"] then + if fishing_setting.settings["worm_is_mob"] == true then + minetest.add_entity({x=pt.under.x, y=pt.under.y+0.4, z=pt.under.z}, "fishing:bait_worm_entity") + else + local inv = user:get_inventory() + if inv:room_for_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""}) then + inv:add_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""}) + end + end + end + itemstack:add_wear(65535/(uses-1)) + return itemstack + end + + -- didn't change the hoes, just here because hoe_on_use is local + minetest.register_tool(":farming:hoe_wood", { + description = fishing_setting.func.S("Wooden Hoe"), + inventory_image = "farming_tool_woodhoe.png", + on_use = function(itemstack, user, pointed_thing) + return hoe_on_use(itemstack, user, pointed_thing, 30) + end, + }) + minetest.register_tool(":farming:hoe_stone", { + description = fishing_setting.func.S("Stone Hoe"), + inventory_image = "farming_tool_stonehoe.png", + on_use = function(itemstack, user, pointed_thing) + return hoe_on_use(itemstack, user, pointed_thing, 90) + end, + }) + minetest.register_tool(":farming:hoe_steel", { + description = fishing_setting.func.S("Steel Hoe"), + inventory_image = "farming_tool_steelhoe.png", + on_use = function(itemstack, user, pointed_thing) + return hoe_on_use(itemstack, user, pointed_thing, 200) + end, + }) + minetest.register_tool(":farming:hoe_bronze", { + description = fishing_setting.func.S("Bronze Hoe"), + inventory_image = "farming_tool_bronzehoe.png", + on_use = function(itemstack, user, pointed_thing) + return hoe_on_use(itemstack, user, pointed_thing, 220) + end, + }) +end