fishing-0.2.1
New water lilies and seaweed (plantlife) can be caught when they share the same space with the bobber. A chance to catch a blue white fish (mobf) when it's near to the bobber.
This commit is contained in:
parent
37aa0d6bfd
commit
9babaf625a
184
bobber.lua
184
bobber.lua
@ -1,5 +1,5 @@
|
|||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
-- Fishing - Mossmanikin's version - Bobber 0.1.6
|
-- Fishing - Mossmanikin's version - Bobber 0.1.7
|
||||||
-- License (code & textures): WTFPL
|
-- License (code & textures): WTFPL
|
||||||
-- Contains code from: fishing (original), mobs, throwing, volcano
|
-- Contains code from: fishing (original), mobs, throwing, volcano
|
||||||
-- Supports: 3d_armor, animal_clownfish, animal_fish_blue_white, animal_rat, flowers_plus, mobs, seaplants
|
-- Supports: 3d_armor, animal_clownfish, animal_fish_blue_white, animal_rat, flowers_plus, mobs, seaplants
|
||||||
@ -25,6 +25,29 @@ local CaTCH = {
|
|||||||
}
|
}
|
||||||
minetest.register_alias("flowers_plus:seaweed", "flowers:seaweed") -- exception
|
minetest.register_alias("flowers_plus:seaweed", "flowers:seaweed") -- exception
|
||||||
|
|
||||||
|
local PLaNTS = {
|
||||||
|
-- MoD* iTeM MeSSaGe ("You caught "..)
|
||||||
|
{"flowers", "waterlily", "a Waterlily." },
|
||||||
|
{"flowers", "waterlily_225", "a Waterlily." },
|
||||||
|
{"flowers", "waterlily_45", "a Waterlily." },
|
||||||
|
{"flowers", "waterlily_675", "a Waterlily." },
|
||||||
|
{"flowers", "waterlily_s1", "a Waterlily." },
|
||||||
|
{"flowers", "waterlily_s2", "a Waterlily." },
|
||||||
|
{"flowers", "waterlily_s3", "a Waterlily." },
|
||||||
|
{"flowers", "waterlily_s4", "a Waterlily." },
|
||||||
|
{"flowers", "seaweed", "some Seaweed."},
|
||||||
|
{"flowers", "seaweed_2", "some Seaweed."},
|
||||||
|
{"flowers", "seaweed_3", "some Seaweed."},
|
||||||
|
{"flowers", "seaweed_4", "some Seaweed."},
|
||||||
|
}
|
||||||
|
-- *as used in the node name
|
||||||
|
|
||||||
|
local MoBS = { -- not in use
|
||||||
|
-- iTeM MeSSaGe ("You caught "..)
|
||||||
|
{"animal_clownfish:clownfish", "a Clownfish." },
|
||||||
|
{"animal_fish_blue_white:fish_blue_white", "a Blue white fish."},
|
||||||
|
}
|
||||||
|
|
||||||
minetest.register_node("fishing:bobber_box", {
|
minetest.register_node("fishing:bobber_box", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = {
|
node_box = {
|
||||||
@ -63,10 +86,13 @@ local FISHING_BOBBER_ENTITY={
|
|||||||
local player = puncher:get_player_name()
|
local player = puncher:get_player_name()
|
||||||
local inv = puncher:get_inventory()
|
local inv = puncher:get_inventory()
|
||||||
if MESSAGES == true then minetest.chat_send_player(player, "You didn't catch anything.", false) end -- fish escaped
|
if MESSAGES == true then minetest.chat_send_player(player, "You didn't catch anything.", false) end -- fish escaped
|
||||||
if inv:room_for_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""}) then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
inv:add_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""})
|
if inv:room_for_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""}) then
|
||||||
if MESSAGES == true then minetest.chat_send_player(player, "The bait is still there.", false) end -- bait still there
|
inv:add_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""})
|
||||||
end
|
if MESSAGES == true then minetest.chat_send_player(player, "The bait is still there.", false) end -- bait still there
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- make sound and remove bobber
|
||||||
minetest.sound_play("fishing_bobber1", {
|
minetest.sound_play("fishing_bobber1", {
|
||||||
pos = self.object:getpos(),
|
pos = self.object:getpos(),
|
||||||
gain = 0.5,
|
gain = 0.5,
|
||||||
@ -79,67 +105,94 @@ local FISHING_BOBBER_ENTITY={
|
|||||||
local player = clicker:get_player_name()
|
local player = clicker:get_player_name()
|
||||||
if item:get_name() == "fishing:pole" then
|
if item:get_name() == "fishing:pole" then
|
||||||
local inv = clicker:get_inventory()
|
local inv = clicker:get_inventory()
|
||||||
--local room_fish = inv:room_for_item("main", {name="fishing:fish_raw", count=1, wear=0, metadata=""})
|
|
||||||
local say = minetest.chat_send_player
|
local say = minetest.chat_send_player
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
if minetest.env:get_node(pos).name == "flowers:waterlily"
|
-- catch visible plant
|
||||||
or minetest.env:get_node(pos).name == "flowers:waterlily_225"
|
if minetest.get_node(pos).name ~= "air" then
|
||||||
or minetest.env:get_node(pos).name == "flowers:waterlily_45"
|
for i in ipairs(PLaNTS) do
|
||||||
or minetest.env:get_node(pos).name == "flowers:waterlily_675" then
|
local PLaNT = PLaNTS[i][1]..":"..PLaNTS[i][2]
|
||||||
minetest.env:add_node({x=pos.x, y=pos.y, z=pos.z}, {name="air"})
|
local MeSSaGe = PLaNTS[i][3]
|
||||||
if inv:room_for_item("main", {name="flowers:waterlily", count=1, wear=WeaR, metadata=""}) then
|
local DRoP = minetest.registered_nodes[PLaNT].drop
|
||||||
inv:add_item("main", {name="flowers:waterlily", count=1, wear=WeaR, metadata=""})
|
if minetest.get_node(pos).name == PLaNT then
|
||||||
if MESSAGES == true then say(player, "You caught a Waterlily", false) end -- caught Waterlily
|
minetest.add_node({x=pos.x, y=pos.y, z=pos.z}, {name="air"})
|
||||||
end
|
if inv:room_for_item("main", {name=DRoP, count=1, wear=0, metadata=""}) then
|
||||||
if inv:room_for_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""}) then
|
inv:add_item("main", {name=DRoP, count=1, wear=0, metadata=""})
|
||||||
inv:add_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""})
|
if MESSAGES == true then say(player, "You caught "..MeSSaGe, false) end -- caught Plant
|
||||||
if MESSAGES == true then say(player, "The bait is still there.", false) end -- bait still there
|
end
|
||||||
end
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
elseif self.object:get_hp() <= 300 then
|
if inv:room_for_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""}) then
|
||||||
if math.random(1, 100) < FISH_CHANCE then
|
inv:add_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""})
|
||||||
local chance = math.random(1, 120) -- ><((((º>
|
if MESSAGES == true then say(player, "The bait is still there.", false) end -- bait still there
|
||||||
for i in pairs(CaTCH) do
|
|
||||||
local MoD = CaTCH[i][1]
|
|
||||||
local iTeM = CaTCH[i][2]
|
|
||||||
local WeaR = CaTCH[i][3]
|
|
||||||
local MeSSaGe = CaTCH[i][4]
|
|
||||||
local GeTBaiTBack = CaTCH[i][5]
|
|
||||||
local NRMiN = CaTCH[i][6]
|
|
||||||
local CHaNCe = CaTCH[i][7]
|
|
||||||
local NRMaX = NRMiN + CHaNCe - 1
|
|
||||||
if chance <= NRMaX and chance >= NRMiN then
|
|
||||||
if minetest.get_modpath(MoD) ~= nil then
|
|
||||||
if inv:room_for_item("main", {name=MoD..":"..iTeM, count=1, wear=WeaR, metadata=""}) then
|
|
||||||
inv:add_item("main", {name=MoD..":"..iTeM, count=1, wear=WeaR, metadata=""})
|
|
||||||
if MESSAGES == true then say(player, "You caught "..MeSSaGe, false) end -- caught somethin'
|
|
||||||
end
|
|
||||||
if GeTBaiTBack == true then
|
|
||||||
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=""})
|
|
||||||
if MESSAGES == true then say(player, "The bait is still there.", false) end -- bait still there?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if inv:room_for_item("main", {name="fishing:fish_raw", count=1, wear=0, metadata=""}) then
|
|
||||||
inv:add_item("main", {name="fishing:fish_raw", count=1, wear=0, metadata=""})
|
|
||||||
if MESSAGES == true then say(player, "You caught a Fish.", false) end -- caught Fish
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- catch visible fish and invisible stuff
|
||||||
|
if self.object:get_hp() <= 300 then
|
||||||
|
if math.random(1, 100) < FISH_CHANCE then
|
||||||
|
local chance = math.random(1, 120) -- ><((((º>
|
||||||
|
for i in pairs(CaTCH) do
|
||||||
|
local MoD = CaTCH[i][1]
|
||||||
|
local iTeM = CaTCH[i][2]
|
||||||
|
local WeaR = CaTCH[i][3]
|
||||||
|
local MeSSaGe = CaTCH[i][4]
|
||||||
|
local GeTBaiTBack = CaTCH[i][5]
|
||||||
|
local NRMiN = CaTCH[i][6]
|
||||||
|
local CHaNCe = CaTCH[i][7]
|
||||||
|
local NRMaX = NRMiN + CHaNCe - 1
|
||||||
|
if chance <= NRMaX and chance >= NRMiN then
|
||||||
|
if minetest.get_modpath(MoD) ~= nil then
|
||||||
|
-- remove visible fish, if there
|
||||||
|
local find_fish = minetest.get_objects_inside_radius({x=pos.x,y=pos.y+0.5,z=pos.z}, 1)
|
||||||
|
for k, obj in pairs(find_fish) do
|
||||||
|
if obj:get_luaentity() ~= nil and obj:get_luaentity().name == "animal_fish_blue_white:fish_blue_white" then
|
||||||
|
MoD = "animal_fish_blue_white"
|
||||||
|
iTeM = "fish_blue_white"
|
||||||
|
WeaR = 0
|
||||||
|
MeSSaGe = "a Blue white fish."
|
||||||
|
obj:remove()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- add (in)visible fish to inventory
|
||||||
|
if inv:room_for_item("main", {name=MoD..":"..iTeM, count=1, wear=WeaR, metadata=""}) then
|
||||||
|
inv:add_item("main", {name=MoD..":"..iTeM, count=1, wear=WeaR, metadata=""})
|
||||||
|
if MESSAGES == true then say(player, "You caught "..MeSSaGe, false) end -- caught somethin'
|
||||||
|
end
|
||||||
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
|
if GeTBaiTBack == true then
|
||||||
|
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=""})
|
||||||
|
if MESSAGES == true then say(player, "The bait is still there.", false) end -- bait still there?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if inv:room_for_item("main", {name="fishing:fish_raw", count=1, wear=0, metadata=""}) then
|
||||||
|
inv:add_item("main", {name="fishing:fish_raw", count=1, wear=0, metadata=""})
|
||||||
|
if MESSAGES == true then say(player, "You caught a Fish.", false) end -- caught Fish
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else --if math.random(1, 100) > FISH_CHANCE then
|
else --if math.random(1, 100) > FISH_CHANCE then
|
||||||
if MESSAGES == true then say(player, "Your fish escaped.", false) end -- fish escaped
|
if MESSAGES == true then say(player, "Your fish escaped.", false) end -- fish escaped
|
||||||
end
|
end
|
||||||
else -- if self.object:get_hp() > 300 then
|
end
|
||||||
|
if self.object:get_hp() > 300 and minetest.get_node(pos).name == "air" then
|
||||||
if MESSAGES == true then say(player, "You didn't catch anything.", false) end -- fish escaped
|
if MESSAGES == true then say(player, "You didn't catch anything.", false) end -- fish escaped
|
||||||
if math.random(1, 2) == 1 then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
if inv:room_for_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""}) then
|
if math.random(1, 2) == 1 then
|
||||||
inv:add_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""})
|
if inv:room_for_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""}) then
|
||||||
if MESSAGES == true then say(player, "The bait is still there.", false) end -- bait still there
|
inv:add_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""})
|
||||||
end
|
if MESSAGES == true then say(player, "The bait is still there.", false) end -- bait still there
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- weither player has fishing pole or not
|
||||||
|
-- make sound and remove bobber
|
||||||
minetest.sound_play("fishing_bobber1", {
|
minetest.sound_play("fishing_bobber1", {
|
||||||
pos = self.object:getpos(),
|
pos = self.object:getpos(),
|
||||||
gain = 0.5,
|
gain = 0.5,
|
||||||
@ -150,7 +203,7 @@ local FISHING_BOBBER_ENTITY={
|
|||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
if BOBBER_CHECK_RADIUS > 0 then
|
if BOBBER_CHECK_RADIUS > 0 then
|
||||||
local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, BOBBER_CHECK_RADIUS)
|
local objs = minetest.get_objects_inside_radius(pos, BOBBER_CHECK_RADIUS)
|
||||||
for k, obj in pairs(objs) do
|
for k, obj in pairs(objs) do
|
||||||
if obj:get_luaentity() ~= nil then
|
if obj:get_luaentity() ~= nil then
|
||||||
if obj:get_luaentity().name == "fishing:bobber_entity" then
|
if obj:get_luaentity().name == "fishing:bobber_entity" then
|
||||||
@ -161,7 +214,7 @@ local FISHING_BOBBER_ENTITY={
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if math.random(1, 4) == 1 then
|
if math.random(1, 4) == 1 then
|
||||||
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/2880*math.pi))
|
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/2880*math.pi))
|
||||||
end
|
end
|
||||||
@ -170,13 +223,29 @@ local FISHING_BOBBER_ENTITY={
|
|||||||
local p = player:getpos()
|
local p = player:getpos()
|
||||||
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
|
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
|
||||||
if dist > self.view_range then
|
if dist > self.view_range then
|
||||||
|
-- make sound and remove bobber
|
||||||
minetest.sound_play("fishing_bobber1", {
|
minetest.sound_play("fishing_bobber1", {
|
||||||
pos = self.object:getpos(),
|
pos = self.object:getpos(),
|
||||||
gain = 0.5,
|
gain = 0.5,
|
||||||
})
|
})
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.object:get_hp() > 310 then
|
||||||
|
local find_fish = minetest.get_objects_inside_radius({x=pos.x,y=pos.y+0.5,z=pos.z}, 1)
|
||||||
|
for k, obj in pairs(find_fish) do
|
||||||
|
if obj:get_luaentity() ~= nil then
|
||||||
|
if obj:get_luaentity().name == "animal_fish_blue_white:fish_blue_white" then
|
||||||
|
if math.random(1, 30) == 1 then
|
||||||
|
self.object:set_hp(310)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local do_env_damage = function(self)
|
local do_env_damage = function(self)
|
||||||
self.object:set_hp(self.object:get_hp()-self.water_damage)
|
self.object:set_hp(self.object:get_hp()-self.water_damage)
|
||||||
if self.object:get_hp() == 600 then
|
if self.object:get_hp() == 600 then
|
||||||
@ -211,6 +280,7 @@ local FISHING_BOBBER_ENTITY={
|
|||||||
self.object:moveto({x=pos.x+(0.001*(math.random(-8, 8))),y=pos.y,z=pos.z+(0.001*(math.random(-8, 8)))})
|
self.object:moveto({x=pos.x+(0.001*(math.random(-8, 8))),y=pos.y,z=pos.z+(0.001*(math.random(-8, 8)))})
|
||||||
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/1440*math.pi))
|
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/1440*math.pi))
|
||||||
elseif self.object:get_hp() == 0 then
|
elseif self.object:get_hp() == 0 then
|
||||||
|
-- make sound and remove bobber
|
||||||
minetest.sound_play("fishing_bobber1", {
|
minetest.sound_play("fishing_bobber1", {
|
||||||
pos = self.object:getpos(),
|
pos = self.object:getpos(),
|
||||||
gain = 0.5,
|
gain = 0.5,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
-- Fishing - Mossmanikin's version - Bobber Shark 0.0.4
|
-- Fishing - Mossmanikin's version - Bobber Shark 0.0.5
|
||||||
-- License (code & textures): WTFPL
|
-- License (code & textures): WTFPL
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -10,6 +10,23 @@ local CaTCH_BiG = {
|
|||||||
{"fishing", "pike", 0, "a Northern Pike.", false, 3, 3}
|
{"fishing", "pike", 0, "a Northern Pike.", false, 3, 3}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local PLaNTS = {
|
||||||
|
-- MoD* iTeM MeSSaGe ("You caught "..)
|
||||||
|
{"flowers", "waterlily", "a Waterlily." },
|
||||||
|
{"flowers", "waterlily_225", "a Waterlily." },
|
||||||
|
{"flowers", "waterlily_45", "a Waterlily." },
|
||||||
|
{"flowers", "waterlily_675", "a Waterlily." },
|
||||||
|
{"flowers", "waterlily_s1", "a Waterlily." },
|
||||||
|
{"flowers", "waterlily_s2", "a Waterlily." },
|
||||||
|
{"flowers", "waterlily_s3", "a Waterlily." },
|
||||||
|
{"flowers", "waterlily_s4", "a Waterlily." },
|
||||||
|
{"flowers", "seaweed", "some Seaweed."},
|
||||||
|
{"flowers", "seaweed_2", "some Seaweed."},
|
||||||
|
{"flowers", "seaweed_3", "some Seaweed."},
|
||||||
|
{"flowers", "seaweed_4", "some Seaweed."},
|
||||||
|
}
|
||||||
|
-- *as used in the node name
|
||||||
|
|
||||||
local FISHING_BOBBER_ENTITY_SHARK={
|
local FISHING_BOBBER_ENTITY_SHARK={
|
||||||
hp_max = 605,
|
hp_max = 605,
|
||||||
water_damage = 1,
|
water_damage = 1,
|
||||||
@ -40,20 +57,28 @@ local FISHING_BOBBER_ENTITY_SHARK={
|
|||||||
if item:get_name() == "fishing:pole" then
|
if item:get_name() == "fishing:pole" then
|
||||||
local inv = clicker:get_inventory()
|
local inv = clicker:get_inventory()
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
if minetest.env:get_node(pos).name == "flowers:waterlily"
|
-- catch visible plant
|
||||||
or minetest.env:get_node(pos).name == "flowers:waterlily_225"
|
if minetest.get_node(pos).name ~= "air" then
|
||||||
or minetest.env:get_node(pos).name == "flowers:waterlily_45"
|
for i in ipairs(PLaNTS) do
|
||||||
or minetest.env:get_node(pos).name == "flowers:waterlily_675" then
|
local PLaNT = PLaNTS[i][1]..":"..PLaNTS[i][2]
|
||||||
minetest.env:add_node({x=pos.x, y=pos.y, z=pos.z}, {name="air"})
|
local MeSSaGe = PLaNTS[i][3]
|
||||||
if inv:room_for_item("main", {name="flowers:waterlily", count=1, wear=WeaR, metadata=""}) then
|
local DRoP = minetest.registered_nodes[PLaNT].drop
|
||||||
inv:add_item("main", {name="flowers:waterlily", count=1, wear=WeaR, metadata=""})
|
if minetest.get_node(pos).name == PLaNT then
|
||||||
if MESSAGES == true then say(player, "You caught a Waterlily", false) end -- caught Waterlily
|
minetest.add_node({x=pos.x, y=pos.y, z=pos.z}, {name="air"})
|
||||||
|
if inv:room_for_item("main", {name=DRoP, count=1, wear=0, metadata=""}) then
|
||||||
|
inv:add_item("main", {name=DRoP, count=1, wear=0, metadata=""})
|
||||||
|
if MESSAGES == true then say(player, "You caught "..MeSSaGe, false) end -- caught Plant
|
||||||
|
end
|
||||||
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
|
if inv:room_for_item("main", {name="fishing:fish_raw", count=1, wear=0, metadata=""}) then
|
||||||
|
inv:add_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""})
|
||||||
|
if MESSAGES == true then say(player, "The bait is still there.", false) end -- bait still there
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if inv:room_for_item("main", {name="fishing:fish_raw", count=1, wear=0, metadata=""}) then
|
end
|
||||||
inv:add_item("main", {name="fishing:fish_raw", count=1, wear=0, metadata=""})
|
if self.object:get_hp() <= 300 then
|
||||||
if MESSAGES == true then say(player, "The bait is still there.", false) end -- bait still there
|
|
||||||
end
|
|
||||||
elseif self.object:get_hp() <= 300 then
|
|
||||||
if math.random(1, 100) < SHARK_CHANCE then
|
if math.random(1, 100) < SHARK_CHANCE then
|
||||||
local chance = math.random(1, 6) -- ><((((º>
|
local chance = math.random(1, 6) -- ><((((º>
|
||||||
for i in pairs(CaTCH_BiG) do
|
for i in pairs(CaTCH_BiG) do
|
||||||
@ -71,10 +96,12 @@ local FISHING_BOBBER_ENTITY_SHARK={
|
|||||||
inv:add_item("main", {name=MoD..":"..iTeM, count=1, wear=WeaR, metadata=""})
|
inv:add_item("main", {name=MoD..":"..iTeM, count=1, wear=WeaR, metadata=""})
|
||||||
if MESSAGES == true then say(player, "You caught "..MeSSaGe, false) end -- caught somethin'
|
if MESSAGES == true then say(player, "You caught "..MeSSaGe, false) end -- caught somethin'
|
||||||
end
|
end
|
||||||
if GeTBaiTBack == true then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
if inv:room_for_item("main", {name="fishing:fish_raw", count=1, wear=0, metadata=""}) then
|
if GeTBaiTBack == true then
|
||||||
inv:add_item("main", {name="fishing:fish_raw", count=1, wear=0, metadata=""})
|
if inv:room_for_item("main", {name="fishing:fish_raw", count=1, wear=0, metadata=""}) then
|
||||||
if MESSAGES == true then say(player, "The bait is still there.", false) end -- bait still there?
|
inv:add_item("main", {name="fishing:fish_raw", count=1, wear=0, metadata=""})
|
||||||
|
if MESSAGES == true then say(player, "The bait is still there.", false) end -- bait still there?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -83,13 +110,16 @@ local FISHING_BOBBER_ENTITY_SHARK={
|
|||||||
else --if math.random(1, 100) > FISH_CHANCE then
|
else --if math.random(1, 100) > FISH_CHANCE then
|
||||||
if MESSAGES == true then say(player, "Your fish escaped.", false) end -- fish escaped
|
if MESSAGES == true then say(player, "Your fish escaped.", false) end -- fish escaped
|
||||||
end
|
end
|
||||||
else
|
end
|
||||||
|
if self.object:get_hp() > 300 and minetest.get_node(pos).name == "air" then
|
||||||
if MESSAGES == true then say(player, "You didn't catch anything.", false) end -- fish escaped
|
if MESSAGES == true then say(player, "You didn't catch anything.", false) end -- fish escaped
|
||||||
if math.random(1, 3) == 1 then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
if inv:room_for_item("main", {name="fishing:fish_raw", count=1, wear=0, metadata=""}) then
|
if math.random(1, 3) == 1 then
|
||||||
inv:add_item("main", {name="fishing:fish_raw", count=1, wear=0, metadata=""})
|
if inv:room_for_item("main", {name="fishing:fish_raw", count=1, wear=0, metadata=""}) then
|
||||||
if MESSAGES == true then say(player, "The bait is still there.", false) end -- bait still there
|
inv:add_item("main", {name="fishing:fish_raw", count=1, wear=0, metadata=""})
|
||||||
end
|
if MESSAGES == true then say(player, "The bait is still there.", false) end -- bait still there
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
44
init.lua
44
init.lua
@ -1,6 +1,6 @@
|
|||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
local title = "Fishing - Mossmanikin's version"
|
local title = "Fishing - Mossmanikin's version"
|
||||||
local version = "0.2.0"
|
local version = "0.2.1"
|
||||||
local mname = "fishing"
|
local mname = "fishing"
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
-- original by wulfsdad (http://forum.minetest.net/viewtopic.php?id=4375)
|
-- original by wulfsdad (http://forum.minetest.net/viewtopic.php?id=4375)
|
||||||
@ -54,33 +54,39 @@ minetest.register_tool("fishing:pole", {
|
|||||||
on_use = function (itemstack, user, pointed_thing)
|
on_use = function (itemstack, user, pointed_thing)
|
||||||
if pointed_thing and pointed_thing.under then
|
if pointed_thing and pointed_thing.under then
|
||||||
local pt = pointed_thing
|
local pt = pointed_thing
|
||||||
local node = minetest.env:get_node(pt.under)
|
local node = minetest.get_node(pt.under)
|
||||||
if string.find(node.name, "default:water") then
|
if string.find(node.name, "default:water") then
|
||||||
local player = user:get_player_name()
|
local player = user:get_player_name()
|
||||||
local inv = user:get_inventory()
|
local inv = user:get_inventory()
|
||||||
if inv:get_stack("main", user:get_wield_index()+1):get_name() == "fishing:bait_worm" then
|
if inv:get_stack("main", user:get_wield_index()+1):get_name() == "fishing:bait_worm" then
|
||||||
inv:remove_item("main", "fishing:bait_worm")
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
|
inv:remove_item("main", "fishing:bait_worm")
|
||||||
|
end
|
||||||
minetest.sound_play("fishing_bobber2", {
|
minetest.sound_play("fishing_bobber2", {
|
||||||
pos = pt.under,
|
pos = pt.under,
|
||||||
gain = 0.5,
|
gain = 0.5,
|
||||||
})
|
})
|
||||||
minetest.env:add_entity({interval = 1,x=pt.under.x, y=pt.under.y+(45/64), z=pt.under.z}, "fishing:bobber_entity")
|
minetest.add_entity({interval = 1,x=pt.under.x, y=pt.under.y+(45/64), z=pt.under.z}, "fishing:bobber_entity")
|
||||||
|
|
||||||
if WEAR_OUT == true then
|
if WEAR_OUT == true
|
||||||
|
and not minetest.setting_getbool("creative_mode") then
|
||||||
return rod_wear(itemstack, user, pointed_thing, 30)
|
return rod_wear(itemstack, user, pointed_thing, 30)
|
||||||
else
|
else
|
||||||
return {name="fishing:pole", count=1, wear=0, metadata=""}
|
return {name="fishing:pole", count=1, wear=0, metadata=""}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if inv:get_stack("main", user:get_wield_index()+1):get_name() == "fishing:fish_raw" then
|
if inv:get_stack("main", user:get_wield_index()+1):get_name() == "fishing:fish_raw" then
|
||||||
inv:remove_item("main", "fishing:fish_raw")
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
|
inv:remove_item("main", "fishing:fish_raw")
|
||||||
|
end
|
||||||
minetest.sound_play("fishing_bobber2", {
|
minetest.sound_play("fishing_bobber2", {
|
||||||
pos = pt.under,
|
pos = pt.under,
|
||||||
gain = 0.5,
|
gain = 0.5,
|
||||||
})
|
})
|
||||||
minetest.env:add_entity({interval = 1,x=pt.under.x, y=pt.under.y+(45/64), z=pt.under.z}, "fishing:bobber_entity_shark")
|
minetest.add_entity({interval = 1,x=pt.under.x, y=pt.under.y+(45/64), z=pt.under.z}, "fishing:bobber_entity_shark")
|
||||||
|
|
||||||
if WEAR_OUT == true then
|
if WEAR_OUT == true
|
||||||
|
and not minetest.setting_getbool("creative_mode") then
|
||||||
return rod_wear(itemstack, user, pointed_thing, 30)
|
return rod_wear(itemstack, user, pointed_thing, 30)
|
||||||
else
|
else
|
||||||
return {name="fishing:pole", count=1, wear=0, metadata=""}
|
return {name="fishing:pole", count=1, wear=0, metadata=""}
|
||||||
@ -94,14 +100,16 @@ minetest.register_tool("fishing:pole", {
|
|||||||
local pt = pointed_thing
|
local pt = pointed_thing
|
||||||
if minetest.get_node(pt.under).name~="default:water_source" and minetest.get_node(pt.under).name~="default:water_flowing" then
|
if minetest.get_node(pt.under).name~="default:water_source" and minetest.get_node(pt.under).name~="default:water_flowing" then
|
||||||
local wear = itemstack:get_wear()
|
local wear = itemstack:get_wear()
|
||||||
print (wear)
|
--print (wear)
|
||||||
local direction = minetest.dir_to_facedir(placer:get_look_dir())
|
local direction = minetest.dir_to_facedir(placer:get_look_dir())
|
||||||
local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
|
--local meta1 = minetest.get_meta(pt.under)
|
||||||
local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
|
local meta = minetest.get_meta(pt.above)
|
||||||
minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="fishing:pole_deco", param2=direction})
|
minetest.set_node(pt.above, {name="fishing:pole_deco", param2=direction})
|
||||||
meta1:set_int("wear", wear)
|
--meta1:set_int("wear", wear)
|
||||||
meta2:set_int("wear", wear)
|
meta:set_int("wear", wear)
|
||||||
itemstack:take_item()
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
|
itemstack:take_item()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
@ -205,7 +213,7 @@ minetest.register_node("fishing:pole_deco", {
|
|||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
on_dig = function(pos, node, digger)
|
on_dig = function(pos, node, digger)
|
||||||
if digger:is_player() and digger:get_inventory() then
|
if digger:is_player() and digger:get_inventory() then
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local wear_out = meta:get_int("wear")
|
local wear_out = meta:get_int("wear")
|
||||||
digger:get_inventory():add_item("main", {name="fishing:pole", count=1, wear=wear_out, metadata=""})
|
digger:get_inventory():add_item("main", {name="fishing:pole", count=1, wear=wear_out, metadata=""})
|
||||||
end
|
end
|
||||||
@ -231,7 +239,7 @@ minetest.register_node(":default:dirt", {
|
|||||||
local tool_in_use = digger:get_wielded_item():get_name()
|
local tool_in_use = digger:get_wielded_item():get_name()
|
||||||
if tool_in_use == "" or tool_in_use == "default:dirt" then
|
if tool_in_use == "" or tool_in_use == "default:dirt" then
|
||||||
if WORM_IS_MOB == true then
|
if WORM_IS_MOB == true then
|
||||||
minetest.env:add_entity({x = pos.x, y = pos.y+0.4, z = pos.z}, "fishing:bait_worm_entity")
|
minetest.add_entity({x = pos.x, y = pos.y+0.4, z = pos.z}, "fishing:bait_worm_entity")
|
||||||
else
|
else
|
||||||
local inv = digger:get_inventory()
|
local inv = digger:get_inventory()
|
||||||
if inv:room_for_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""}) then
|
if inv:room_for_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""}) then
|
||||||
@ -288,7 +296,7 @@ local function hoe_on_use(itemstack, user, pointed_thing, uses)
|
|||||||
|
|
||||||
if math.random(1, 100) < WORM_CHANCE then
|
if math.random(1, 100) < WORM_CHANCE then
|
||||||
if WORM_IS_MOB == true then
|
if WORM_IS_MOB == true then
|
||||||
minetest.env:add_entity({x=pt.under.x, y=pt.under.y+0.4, z=pt.under.z}, "fishing:bait_worm_entity")
|
minetest.add_entity({x=pt.under.x, y=pt.under.y+0.4, z=pt.under.z}, "fishing:bait_worm_entity")
|
||||||
else
|
else
|
||||||
local inv = user:get_inventory()
|
local inv = user:get_inventory()
|
||||||
if inv:room_for_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""}) then
|
if inv:room_for_item("main", {name="fishing:bait_worm", count=1, wear=0, metadata=""}) then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user