finished rewriting
							
								
								
									
										11
									
								
								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 | ||||
|  | ||||
|  | ||||
|   | ||||
							
								
								
									
										19
									
								
								amorce.lua
									
									
									
									
									
								
							
							
						
						| @@ -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"} | ||||
| }) | ||||
							
								
								
									
										56
									
								
								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"} | ||||
| }) | ||||
|   | ||||
							
								
								
									
										21
									
								
								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 } | ||||
|  | ||||
|   | ||||
							
								
								
									
										73
									
								
								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) | ||||
|   | ||||
							
								
								
									
										194
									
								
								bobber_shark.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -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) | ||||
| @@ -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 <true|false>") | ||||
| 		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) | ||||
| ]] | ||||
							
								
								
									
										209
									
								
								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"} | ||||
| }) | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -1,2 +1,9 @@ | ||||
| default | ||||
| unified_inventory? | ||||
| farming | ||||
| moreblocks? | ||||
| ropes? | ||||
| moreores? | ||||
| mobs? | ||||
| flowers_plus? | ||||
| seaplants? | ||||
|   | ||||
							
								
								
									
										44
									
								
								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), | ||||
| }) | ||||
| 	----------------------------------------------------- | ||||
|   | ||||
							
								
								
									
										256
									
								
								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 | ||||
| }) | ||||
|  | ||||
|   | ||||
							
								
								
									
										62
									
								
								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...") | ||||
| ----------------------------------------------------------------------------------------------- | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
							
								
								
									
										85
									
								
								locale/fr.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -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 | ||||
|  | ||||
| @@ -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 =  | ||||
|  | ||||
|   | ||||
							
								
								
									
										35
									
								
								material.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -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' }, | ||||
| }) | ||||
							
								
								
									
										17
									
								
								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 | ||||
|  | ||||
|   | ||||
							
								
								
									
										36
									
								
								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) | ||||
|  | ||||
|   | ||||
| @@ -1,3 +0,0 @@ | ||||
|  | ||||
|  | ||||
| random_objects = {} | ||||
| @@ -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 | ||||
|   | ||||
| Before Width: | Height: | Size: 207 B | 
| Before Width: | Height: | Size: 193 B | 
| Before Width: | Height: | Size: 295 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/fishing_bait_bread.png
									
									
									
									
									
										Executable file
									
								
							
							
						
						| After Width: | Height: | Size: 596 B | 
							
								
								
									
										0
									
								
								textures/fishing_bait_corn.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 540 B After Width: | Height: | Size: 540 B | 
							
								
								
									
										0
									
								
								textures/fishing_worm.png → textures/fishing_bait_worm.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 280 B After Width: | Height: | Size: 280 B | 
							
								
								
									
										0
									
								
								textures/fishing_baitball.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 503 B After Width: | Height: | Size: 503 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/fishing_baitball_shark.png
									
									
									
									
									
										Executable file
									
								
							
							
						
						| After Width: | Height: | Size: 569 B | 
							
								
								
									
										0
									
								
								textures/animal_fish_blue_white_fish_blue_white_item.png → textures/fishing_bluefish.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 317 B After Width: | Height: | Size: 317 B | 
							
								
								
									
										0
									
								
								textures/fishing_bobber.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 580 B After Width: | Height: | Size: 580 B | 
							
								
								
									
										0
									
								
								textures/fishing_bobber_bottom.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 205 B After Width: | Height: | Size: 205 B | 
							
								
								
									
										0
									
								
								textures/fishing_bobber_feather_1.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 352 B After Width: | Height: | Size: 352 B | 
							
								
								
									
										0
									
								
								textures/alternates/fishing_bobber.png → textures/fishing_bobber_shark.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 541 B After Width: | Height: | Size: 541 B | 
							
								
								
									
										0
									
								
								textures/fishing_bobber_top.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 205 B After Width: | Height: | Size: 205 B | 
							
								
								
									
										0
									
								
								textures/animal_clownfish_clownfish_item.png → textures/fishing_clownfish.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 352 B After Width: | Height: | Size: 352 B | 
							
								
								
									
										0
									
								
								textures/fishing_deco_pike.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 508 B After Width: | Height: | Size: 508 B | 
							
								
								
									
										0
									
								
								textures/fishing_fish.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 486 B After Width: | Height: | Size: 486 B | 
							
								
								
									
										0
									
								
								textures/fishing_fish_cooked.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 846 B After Width: | Height: | Size: 846 B | 
							
								
								
									
										0
									
								
								textures/fishing_particle_baitball.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 180 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/fishing_particle_baitball_shark.png
									
									
									
									
									
										Executable file
									
								
							
							
						
						| After Width: | Height: | Size: 223 B | 
							
								
								
									
										0
									
								
								textures/fishing_pike.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 297 B After Width: | Height: | Size: 297 B | 
							
								
								
									
										0
									
								
								textures/fishing_pike_cooked.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 702 B After Width: | Height: | Size: 702 B | 
							
								
								
									
										0
									
								
								textures/fishing_pole_perfect.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 284 B After Width: | Height: | Size: 284 B | 
							
								
								
									
										0
									
								
								textures/fishing_pole_perfect_back.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 177 B After Width: | Height: | Size: 177 B | 
							
								
								
									
										0
									
								
								textures/fishing_pole_perfect_bottom.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 185 B After Width: | Height: | Size: 185 B | 
							
								
								
									
										0
									
								
								textures/fishing_pole_perfect_front.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 186 B After Width: | Height: | Size: 186 B | 
							
								
								
									
										0
									
								
								textures/fishing_pole_perfect_simple.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 332 B After Width: | Height: | Size: 332 B | 
							
								
								
									
										0
									
								
								textures/fishing_pole_perfect_top.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 190 B After Width: | Height: | Size: 190 B | 
							
								
								
									
										0
									
								
								textures/fishing_pole_wood.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 265 B After Width: | Height: | Size: 265 B | 
							
								
								
									
										0
									
								
								textures/fishing_pole_wood_back.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 235 B After Width: | Height: | Size: 235 B | 
							
								
								
									
										0
									
								
								textures/fishing_pole_wood_bottom.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 215 B After Width: | Height: | Size: 215 B | 
							
								
								
									
										0
									
								
								textures/fishing_pole_wood_deco.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 354 B After Width: | Height: | Size: 354 B | 
							
								
								
									
										0
									
								
								textures/fishing_pole_wood_front.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 214 B After Width: | Height: | Size: 214 B | 
							
								
								
									
										0
									
								
								textures/fishing_pole_wood_simple.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 303 B After Width: | Height: | Size: 303 B | 
							
								
								
									
										0
									
								
								textures/fishing_pole_wood_top.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 197 B After Width: | Height: | Size: 197 B | 
							
								
								
									
										0
									
								
								textures/fishing_shark.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 389 B After Width: | Height: | Size: 389 B | 
							
								
								
									
										0
									
								
								textures/fishing_shark_cooked.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 763 B After Width: | Height: | Size: 763 B | 
							
								
								
									
										0
									
								
								textures/fishing_sushi.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 590 B After Width: | Height: | Size: 590 B | 
							
								
								
									
										0
									
								
								textures/fishing_trophy_label.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 201 B | 
| Before Width: | Height: | Size: 352 B | 
| Before Width: | Height: | Size: 363 B | 
| Before Width: | Height: | Size: 222 B | 
| Before Width: | Height: | Size: 238 B | 
| Before Width: | Height: | Size: 217 B | 
| Before Width: | Height: | Size: 238 B | 
| Before Width: | Height: | Size: 269 B | 
| Before Width: | Height: | Size: 391 B | 
							
								
								
									
										84
									
								
								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 | ||||
|   | ||||
							
								
								
									
										245
									
								
								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 | ||||
|   | ||||