Browse Source

fix typo

add support to modpack mobs_fish and mobs_sharks, fish|sharks mobs can be now catched
re-add craft worms with 2 dirt
tags/v1.0.0
crabman77 4 years ago
parent
commit
fe52e29d0e
12 changed files with 194 additions and 41 deletions
  1. +7
    -0
      baits.lua
  2. +41
    -12
      bobber.lua
  3. +37
    -8
      bobber_shark.lua
  4. +36
    -0
      crafting.lua
  5. +2
    -0
      depends.txt
  6. +32
    -18
      functions.lua
  7. +6
    -1
      init.lua
  8. +5
    -0
      locale/de.txt
  9. +2
    -1
      locale/fr.txt
  10. +2
    -0
      locale/template.txt
  11. +15
    -1
      prizes.lua
  12. +9
    -0
      worms.lua

+ 7
- 0
baits.lua View File

@@ -28,3 +28,10 @@ fishing_setting.baits["fishing:clownfish_raw"] = { ["bait"] = "fishing:clownfish
fishing_setting.baits["fishing:bluewhite_raw"] = { ["bait"] = "fishing:bluewhite_raw", ["bobber"] = "fishing:bobber_shark_entity",["texture"] = "fishing_bluewhite_raw.png", ["hungry"] = 50 }

fishing_setting.baits["fishing:exoticfish_raw"] = { ["bait"] = "fishing:exoticfish_raw", ["bobber"] = "fishing:bobber_shark_entity",["texture"] = "fishing_exoticfish_raw.png", ["hungry"] = 50 }

-- to mob_fish modpack
if (minetest.get_modpath("mobs_fish")) then
fishing_setting.baits["mobs_fish:clownfish"] = { ["bait"] = "mobs_fish:clownfish", ["bobber"] = "fishing:bobber_shark_entity", ["hungry"] = 50 }
fishing_setting.baits["mobs_fish:tropical"] = { ["bait"] = "mobs_fish:tropical", ["bobber"] = "fishing:bobber_shark_entity", ["hungry"] = 50 }
end


+ 41
- 12
bobber.lua View File

@@ -48,14 +48,18 @@ local FISHING_BOBBER_ENTITY={
-- DESTROY BOBBER WHEN PUNCHING IT
on_punch = function (self, puncher, time_from_last_punch, tool_capabilities, dir)
if not puncher:is_player() then return end
local player = puncher:get_player_name()
if playername ~= self.owner then return end
if fishing_setting.settings["message"] == true then minetest.chat_send_player(playername, fishing_setting.func.S("You didn't catch anything."), false) end
local player_name = puncher:get_player_name()
if player_name ~= self.owner then return end
if fishing_setting.settings["message"] == true then
minetest.chat_send_player(player_name, fishing_setting.func.S("You didn't catch anything."), false)
end
if not fishing_setting.is_creative_mode then
local inv = puncher:get_inventory()
if inv:room_for_item("main", {name=self.bait, count=1, wear=0, metadata=""}) then
inv:add_item("main", {name=self.bait, count=1, wear=0, metadata=""})
if fishing_setting.settings["message"] == true then minetest.chat_send_player(playername, fishing_setting.func.S("The bait is still there."), false) end
if fishing_setting.settings["message"] == true then
minetest.chat_send_player(player_name, fishing_setting.func.S("The bait is still there."), false)
end
end
end
-- make sound and remove bobber
@@ -67,19 +71,19 @@ local FISHING_BOBBER_ENTITY={
-- WHEN RIGHTCLICKING THE BOBBER THE FOLLOWING HAPPENS (CLICK AT THE RIGHT TIME WHILE HOLDING A FISHING POLE)
on_rightclick = function (self, clicker)
local item = clicker:get_wielded_item()
local playername = clicker:get_player_name()
local player_name = clicker:get_player_name()
local inv = clicker:get_inventory()
local pos = self.object:getpos()
local item_name = item:get_name()
if string.find(item_name, "fishing:pole_") ~= nil then
if playername ~= self.owner then return end
if player_name ~= self.owner then return end
if self.prize ~= "" then
if math.random(1, 100) <= fishing_setting.settings["escape_chance"] then
if fishing_setting.settings["message"] == true then minetest.chat_send_player(playername, fishing_setting.func.S("Your fish escaped."), false) end -- fish escaped
if fishing_setting.settings["message"] == true then minetest.chat_send_player(player_name, fishing_setting.func.S("Your fish escaped."), false) end -- fish escaped
else
local name = self.prize[1]..":"..self.prize[2]
local desc = self.prize[4]
if fishing_setting.settings["message"] == true then minetest.chat_send_player(playername, fishing_setting.func.S("You caught "..desc), false) end
if fishing_setting.settings["message"] == true then minetest.chat_send_player(player_name, fishing_setting.func.S("You caught "..desc), false) end
fishing_setting.func.add_to_trophies(clicker, self.prize[2], desc)
local wear_value = fishing_setting.func.wear_value(self.prize[3])
if inv:room_for_item("main", {name=name, count=1, wear=wear_value, metadata=""}) then
@@ -88,6 +92,12 @@ local FISHING_BOBBER_ENTITY={
minetest.spawn_item(clicker:getpos(), {name=name, count=1, wear=wear_value, metadata=""})
end
end
else
if not fishing_setting.is_creative_mode then
if inv:room_for_item("main", {name=self.bait, count=1, wear=0, metadata=""}) then
inv:add_item("main", {name=self.bait, count=1, wear=0, metadata=""})
end
end
end
-- weither player has fishing pole or not
minetest.sound_play("fishing_bobber1", { pos = self.object:getpos(), gain = 0.5, })
@@ -120,7 +130,9 @@ local FISHING_BOBBER_ENTITY={
--remove if not node water
local node = minetest.get_node_or_nil({x=pos.x, y=pos.y-0.5, z=pos.z})
if not node or string.find(node.name, "water_source") == nil then
if fishing_setting.settings["message"] == true then minetest.chat_send_player(self.owner, "Haha, Fishing is prohibited outside water!") end
if fishing_setting.settings["message"] == true then
minetest.chat_send_player(self.owner, "Haha, Fishing is prohibited outside water!")
end
self.object:remove()
return
end
@@ -158,6 +170,9 @@ local FISHING_BOBBER_ENTITY={

--change item on line
self.timer = 0
if self.prize ~= "" and fishing_setting.have_true_fish and fishing_setting.prizes["true_fish"]["little"][self.prize[1]..":"..self.prize[2]] then
minetest.add_entity({x=pos.x, y=pos.y-1, z=pos.z}, self.prize[1]..":"..self.prize[2])
end
self.prize = ""
self.object:moveto(self.old_pos, false)
--Once the fish are not hungry :), baitball increase hungry + 20%
@@ -174,10 +189,24 @@ local FISHING_BOBBER_ENTITY={
else
self.prize = fishing_setting.prizes["rivers"]["little"][math.random(1,#fishing_setting.prizes["rivers"]["little"])]
end
else
if math.random(1, 100) <= 10 then
self.prize = fishing_setting.func.get_loot()

-- to mobs_fish modpack
if fishing_setting.have_true_fish then
local objs = minetest.get_objects_inside_radius({x=pos.x, y=pos.y-1, z=pos.z}, 1)
for _, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then
local name = obj:get_luaentity().name
if fishing_setting.prizes["true_fish"]["little"][name] then
self.prize = fishing_setting.prizes["true_fish"]["little"][name]
obj:remove()
self.randomtime = math.random(3,7)*10
break
end
end
end
end
elseif math.random(1, 100) <= 10 then
self.prize = fishing_setting.func.get_loot()
end

if self.prize ~= "" then


+ 37
- 8
bobber_shark.lua View File

@@ -48,12 +48,16 @@ local FISHING_BOBBER_SHARK_ENTITY={
if not puncher:is_player() then return end
local player_name = puncher:get_player_name()
if player_name ~= self.owner then return end
if fishing_setting.settings["message"] == true then minetest.chat_send_player(player_name, fishing_setting.func.S("You didn't catch anything."), false) end
if fishing_setting.settings["message"] == true then
minetest.chat_send_player(player_name, fishing_setting.func.S("You didn't catch anything."), false)
end
if not fishing_setting.is_creative_mode then
local inv = puncher:get_inventory()
if inv:room_for_item("main", {name=self.bait, count=1, wear=0, metadata=""}) then
inv:add_item("main", {name=self.bait, count=1, wear=0, metadata=""})
if fishing_setting.settings["message"] == true then minetest.chat_send_player(player_name, fishing_setting.func.S("The bait is still there."), false) end
if fishing_setting.settings["message"] == true then
minetest.chat_send_player(player_name, fishing_setting.func.S("The bait is still there."), false)
end
end
end
-- make sound and remove bobber
@@ -86,6 +90,12 @@ local FISHING_BOBBER_SHARK_ENTITY={
minetest.spawn_item(clicker:getpos(), {name=name, count=1, wear=wear_value, metadata=""})
end
end
else
if not fishing_setting.is_creative_mode then
if inv:room_for_item("main", {name=self.bait, count=1, wear=0, metadata=""}) then
inv:add_item("main", {name=self.bait, count=1, wear=0, metadata=""})
end
end
end
-- weither player has fishing pole or not
minetest.sound_play("fishing_bobber1", { pos = self.object:getpos(), gain = 0.5, })
@@ -118,7 +128,9 @@ local FISHING_BOBBER_SHARK_ENTITY={
--remove if not node water
local node = minetest.get_node_or_nil({x=pos.x, y=pos.y-0.5, z=pos.z})
if not node or string.find(node.name, "water_source") == nil then
if fishing_setting.settings["message"] == true then minetest.chat_send_player(self.owner, fishing_setting.func.S("Haha, Fishing is prohibited outside water!")) end
if fishing_setting.settings["message"] == true then
minetest.chat_send_player(self.owner, fishing_setting.func.S("Haha, Fishing is prohibited outside water!"))
end
self.object:remove()
return
end
@@ -156,6 +168,9 @@ local FISHING_BOBBER_SHARK_ENTITY={

--change item on line
self.timer = 0
if self.prize ~= "" and fishing_setting.have_true_fish and fishing_setting.prizes["true_fish"]["big"][self.prize[1]..":"..self.prize[2]] then
minetest.add_entity({x=pos.x, y=pos.y-1, z=pos.z}, self.prize[1]..":"..self.prize[2])
end
self.prize = ""
self.object:moveto(self.old_pos, false)
--Once the fish are not hungry :), baitball increase hungry + 20%
@@ -168,8 +183,8 @@ local FISHING_BOBBER_SHARK_ENTITY={
self.randomtime = math.random(1,5)*10
local chance = math.random(1, 100)
--if 1 you catch a treasure
if chance == 1 then
if math.random(1, 100) <= fishing_setting.settings["treasure_chance"] and fishing_setting.settings["treasure_enable"] then
if fishing_setting.settings["treasure_enable"] and chance == 1 then
if math.random(1, 100) <= fishing_setting.settings["treasure_chance"] then
self.prize = fishing_setting.prizes["treasure"][math.random(1,#fishing_setting.prizes["treasure"])]
end
elseif chance <= fishing_setting.settings["fish_chance"] then
@@ -178,10 +193,24 @@ local FISHING_BOBBER_SHARK_ENTITY={
else
self.prize = fishing_setting.prizes["rivers"]["big"][math.random(1,#fishing_setting.prizes["rivers"]["big"])]
end
else
if math.random(1, 100) <= 10 then
self.prize = fishing_setting.func.get_loot()

-- to mobs_fish modpack
if fishing_setting.have_true_fish then
local objs = minetest.get_objects_inside_radius({x=pos.x, y=pos.y-2, z=pos.z}, 3)
for _, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then
local name = obj:get_luaentity().name
if fishing_setting.prizes["true_fish"]["big"][name] then
self.prize = fishing_setting.prizes["true_fish"]["big"][name]
obj:remove()
self.randomtime = math.random(3,7)*10
break
end
end
end
end
elseif math.random(1, 100) <= 10 then
self.prize = fishing_setting.func.get_loot()
end

if self.prize ~= "" then


+ 36
- 0
crafting.lua View File

@@ -127,6 +127,21 @@ minetest.register_craft({
cooktime = 2,
})

if minetest.get_modpath("mobs_fish") ~= nil then
minetest.register_craft({
type = "cooking",
output = "fishing:fish_cooked",
recipe = "mobs_fish:clownfish",
cooktime = 2,
})
minetest.register_craft({
type = "cooking",
output = "fishing:fish_cooked",
recipe = "mobs_fish:tropical",
cooktime = 2,
})
end

-----------------------------------------------------------------------------------------------
-- Wheat Seed
-----------------------------------------------------------------------------------------------
@@ -166,6 +181,27 @@ minetest.register_craft({
cooktime = 2,
})

if minetest.get_modpath("mobs_sharks") ~= nil then
minetest.register_craft({
type = "cooking",
output = "fishing:shark_cooked",
recipe = "mobs_sharks:shark_lg",
cooktime = 2,
})
minetest.register_craft({
type = "cooking",
output = "fishing:shark_cooked",
recipe = "mobs_sharks:shark_md",
cooktime = 2,
})
minetest.register_craft({
type = "cooking",
output = "fishing:shark_cooked",
recipe = "mobs_sharks:shark_sm",
cooktime = 2,
})
end

-----------------------------------------------------------------------------------------------
-- Roasted Pike
-----------------------------------------------------------------------------------------------


+ 2
- 0
depends.txt View File

@@ -7,3 +7,5 @@ moreores?
mobs?
flowers_plus?
seaplants?
mobs_fish?
mobs_sharks?

+ 32
- 18
functions.lua View File

@@ -102,8 +102,19 @@ end
--function random hungry by bait type
function fishing_setting.func.hungry_random()
for i,a in pairs(fishing_setting.baits) do
fishing_setting.baits[i]["hungry"] = math.random(15, 80)
if string.find(i, "fishing:") ~= nil then
fishing_setting.baits[i]["hungry"] = math.random(15, 80)
end
end
-- to mobs_fish modpack
if fishing_setting.baits["mobs_fish:clownfish"] then
fishing_setting.baits["mobs_fish:clownfish"]["hungry"] = fishing_setting.baits["fishing:clownfish_raw"]["hungry"]
end
if fishing_setting.baits["mobs_fish:tropical"] then
fishing_setting.baits["mobs_fish:tropical"]["hungry"] = fishing_setting.baits["fishing:exoticfish_raw"]["hungry"]
end

--change hungry after random time, min 0h30, max 6h00
minetest.after(math.random(1, 12)*1800,function() fishing_setting.func.hungry_random() end)
end
@@ -344,22 +355,23 @@ end)
function fishing_setting.func.add_to_trophies(player, fish, desc)
local player_name = player:get_player_name()
if not player_name then return end
if string.find(fish, "_raw") ~= nil then
if fishing_setting.trophies[fish] == nil then
fishing_setting.trophies[fish] = {}
end
fishing_setting.trophies[fish][player_name] = (fishing_setting.trophies[fish][player_name] or 0) + 1
if fishing_setting.trophies[fish][player_name]%100 == 0 then
minetest.chat_send_player(player_name, S("You win a new trophy, you have caught %s " .. fish.."."):format(fishing_setting.trophies[fish][player_name]))
local inv = player:get_inventory()
local name = "fishing:trophy_"..fish
if inv:room_for_item("main", {name=name, count=1, wear=0, metadata=""}) then
inv:add_item("main", {name=name, count=1, wear=0, metadata=""})
else
minetest.spawn_item(player:getpos(), {name=name, count=1, wear=0, metadata=""})
if string.find(fish, "_raw") ~= nil or fishing_setting.prizes["true_fish"]["little"][fish] or fishing_setting.prizes["true_fish"]["big"][fish] then
if string.find(fish, "_raw") ~= nil then
if fishing_setting.trophies[fish] == nil then
fishing_setting.trophies[fish] = {}
end
fishing_setting.trophies[fish][player_name] = (fishing_setting.trophies[fish][player_name] or 0) + 1
if fishing_setting.trophies[fish][player_name]%100 == 0 then
minetest.chat_send_player(player_name, S("You win a new trophy, you have caught %s " .. fish.."."):format(fishing_setting.trophies[fish][player_name]))
local inv = player:get_inventory()
local name = "fishing:trophy_"..fish
if inv:room_for_item("main", {name=name, count=1, wear=0, metadata=""}) then
inv:add_item("main", {name=name, count=1, wear=0, metadata=""})
else
minetest.spawn_item(player:getpos(), {name=name, count=1, wear=0, metadata=""})
end
end
end

if fishing_setting.contest["contest"] ~= nil and fishing_setting.contest["contest"] == true then
if fishing_setting.contest["nb_fish"] == nil then
fishing_setting.contest["nb_fish"] = {}
@@ -582,9 +594,11 @@ function fishing_setting.func.get_hunger_info(player_name)
local formspec = "size[6,9]label[1.9,0;Fishing Info Center]"
local y = 0.8
for i, a in pairs(fishing_setting.baits) do
formspec = formspec .."item_image_button[1,"..tostring(y)..";1,1;"..tostring(i)..";"..tostring(i)..";]"..
"label[2.2,"..tostring(y+0.2)..";Chance to fish :"..tostring(a["hungry"]).."%]"
y = y+1
if string.find(i, "fishing:") ~= nil then
formspec = formspec .."item_image_button[1,"..tostring(y)..";1,1;"..tostring(i)..";"..tostring(i)..";]"..
"label[2.2,"..tostring(y+0.2)..";Chance to fish :"..tostring(a["hungry"]).."%]"
y = y+1
end
end
formspec = formspec .."button_exit[2,8.5;2,1;close;"..S("Close").."]"
minetest.show_formspec(player_name,"fishing:material_info", formspec)


+ 6
- 1
init.lua View File

@@ -1,6 +1,6 @@
-----------------------------------------------------------------------------------------------
local title = "Fishing - Crabman77's version"
local version = "0.0.3"
local version = "0.0.4"
local mname = "fishing"
-----------------------------------------------------------------------------------------------
-- original by wulfsdad (http://forum.minetest.net/viewtopic.php?id=4375)
@@ -55,6 +55,11 @@ fishing_setting.settings["treasure_chance"] = TREASURE_CHANCE
fishing_setting.settings["treasure_enable"] = TREASURE_RANDOM_ENABLE
fishing_setting.settings["escape_chance"] = ESCAPE_CHANCE

-- to mobs_fish|mobs_sharks modpack
if (minetest.get_modpath("mobs_fish") ~= nil or minetest.get_modpath("mobs_sharks") ~= nil) then
fishing_setting.have_true_fish = true
end

-- load config file if exist in worldpath
fishing_setting.func.load()



+ 5
- 0
locale/de.txt View File

@@ -8,6 +8,11 @@ Your fish escaped. = Dein Fisch ist entkommen.
You caught a Fish. = Du hast einen Fisch gefangen.
You caught a Clownfish. = Du hast einen Clownfisch gefangen.
You caught a Bluewhite. = Du hast einen blau-weissen Fisch gefangen.
You caught a Carp. =
You caught a Perch. =
You caught a Catfish. =
You caught a Exoticfish. =
You caught a tropical fish. =
You caught a Twig. = Du hast einen Zweig gefangen.
You caught a Rat. = Du hast eine Ratte gefangen.
You caught some Seaweed. = Du hast etwas Seetang gefangen.


+ 2
- 1
locale/fr.txt View File

@@ -14,7 +14,8 @@ You caught a Carp. = Vous avez attrape une carpe.
You caught a Perch. = Vous avez attrape une perche.
You caught a Catfish. = Vous avez attrape un poisson chat.
You caught a Exoticfish. = Vous avez attrape un poisson exotic.
You caught a Twig. = Vous avez attrape une brindille .
You caught a Tropical fish. = Vous avez attrape un poisson tropicale.
You caught a Twig. = Vous avez attrape une brindille.
You caught a Rat. = Vous avez attrape un rat.
You caught some Seaweed. = Vous avez attrape des algues.
You caught a Green Kelp. = Vous avez attrape une algue verte.


+ 2
- 0
locale/template.txt View File

@@ -10,10 +10,12 @@ The bait is still there. =
Your fish escaped. =
You caught a Fish. =
You caught a Clownfish. =
You caught a Bluewhite. =
You caught a Carp. =
You caught a Perch. =
You caught a Catfish. =
You caught a Exoticfish. =
You caught a tropical fish. =
You caught a Twig. =
You caught a Rat. =
You caught some Seaweed. =


+ 15
- 1
prizes.lua View File

@@ -24,7 +24,6 @@ fishing_setting.prizes["sea"]["big"] = {
}



local stuff = {
-- mod item wear message ("You caught "..) nrmin chance (1/67)
{"flowers", "seaweed", 0, "some Seaweed.", 1, 5},
@@ -57,3 +56,18 @@ local treasure = {
}
fishing_setting.prizes["treasure"] = fishing_setting.func.ignore_mod(treasure)


-- to true fish mobs
fishing_setting.prizes["true_fish"] = {little = {}, big = {}}
--to mobs_fish modpack
if (minetest.get_modpath("mobs_fish")) then
fishing_setting.prizes["true_fish"]["little"]["mobs_fish:clownfish"] = {"mobs_fish", "clownfish", 0, "a Clownfish."}
fishing_setting.prizes["true_fish"]["little"]["mobs_fish:tropical"] = {"mobs_fish", "tropical", 0, "a tropical fish."}
end
--to mobs_fish modpack
if (minetest.get_modpath("mobs_sharks")) then
fishing_setting.prizes["true_fish"]["big"]["mobs_sharks:shark_lg"] = {"mobs_sharks", "shark_lg", 0, "a small Shark."}
fishing_setting.prizes["true_fish"]["big"]["mobs_sharks:shark_md"] = {"mobs_sharks", "shark_md", 0, "a small Shark."}
fishing_setting.prizes["true_fish"]["big"]["mobs_sharks:shark_sm"] = {"mobs_sharks", "shark_sm", 0, "a small Shark."}
end


+ 9
- 0
worms.lua View File

@@ -122,6 +122,15 @@ minetest.register_entity("fishing:bait_worm_entity", {
end,
})

--- Bait Worm Entity
minetest.register_craft({
output = "fishing:bait_worm 8",
recipe = {
{"default:dirt"},
{"default:dirt"},
}
})

-----------------------------------------------------------------------------------------------
-- GETTING WORMS
-----------------------------------------------------------------------------------------------


Loading…
Cancel
Save