forked from mtcontrib/bonemeal
		
	only use bonemeal items when actually used.
This commit is contained in:
		
							
								
								
									
										37
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								init.lua
									
									
									
									
									
								
							@@ -181,7 +181,7 @@ local function check_sapling(pos, nodename)
 | 
				
			|||||||
			if can_grow then
 | 
								if can_grow then
 | 
				
			||||||
				particle_effect(pos)
 | 
									particle_effect(pos)
 | 
				
			||||||
				grow_tree(pos, saplings[n][2])
 | 
									grow_tree(pos, saplings[n][2])
 | 
				
			||||||
				return
 | 
									return true
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
@@ -216,7 +216,7 @@ local function check_crops(pos, nodename, strength)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			particle_effect(pos)
 | 
								particle_effect(pos)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			return
 | 
								return true
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
@@ -438,13 +438,13 @@ function bonemeal:on_use(pos, strength, node)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		default.grow_papyrus(pos, node)
 | 
							default.grow_papyrus(pos, node)
 | 
				
			||||||
		particle_effect(pos)
 | 
							particle_effect(pos)
 | 
				
			||||||
		return
 | 
							return true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	elseif node.name == "default:cactus" then
 | 
						elseif node.name == "default:cactus" then
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		default.grow_cactus(pos, node)
 | 
							default.grow_cactus(pos, node)
 | 
				
			||||||
		particle_effect(pos)
 | 
							particle_effect(pos)
 | 
				
			||||||
		return
 | 
							return true
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	-- grow grass and flowers
 | 
						-- grow grass and flowers
 | 
				
			||||||
@@ -452,7 +452,7 @@ function bonemeal:on_use(pos, strength, node)
 | 
				
			|||||||
	or minetest.get_item_group(node.name, "sand") > 0
 | 
						or minetest.get_item_group(node.name, "sand") > 0
 | 
				
			||||||
	or minetest.get_item_group(node.name, "can_bonemeal") > 0 then
 | 
						or minetest.get_item_group(node.name, "can_bonemeal") > 0 then
 | 
				
			||||||
		check_soil(pos, node.name, strength)
 | 
							check_soil(pos, node.name, strength)
 | 
				
			||||||
		return
 | 
							return true
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	-- light check depending on strength (strength of 4 = no light needed)
 | 
						-- light check depending on strength (strength of 4 = no light needed)
 | 
				
			||||||
@@ -464,11 +464,13 @@ function bonemeal:on_use(pos, strength, node)
 | 
				
			|||||||
	if minetest.get_item_group(node.name, "sapling") > 0
 | 
						if minetest.get_item_group(node.name, "sapling") > 0
 | 
				
			||||||
	and random(5 - strength) == 1 then
 | 
						and random(5 - strength) == 1 then
 | 
				
			||||||
		check_sapling(pos, node.name)
 | 
							check_sapling(pos, node.name)
 | 
				
			||||||
		return
 | 
							return true
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	-- check for crop growth
 | 
						-- check for crop growth
 | 
				
			||||||
	check_crops(pos, node.name, strength)
 | 
						if check_crops(pos, node.name, strength) then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -494,13 +496,14 @@ minetest.register_craftitem("bonemeal:mulch", {
 | 
				
			|||||||
			return
 | 
								return
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							-- call global on_use function with strength of 1
 | 
				
			||||||
 | 
							if bonemeal:on_use(pointed_thing.under, 1) then
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			-- take item if not in creative
 | 
								-- take item if not in creative
 | 
				
			||||||
			if not bonemeal.is_creative(user:get_player_name()) then
 | 
								if not bonemeal.is_creative(user:get_player_name()) then
 | 
				
			||||||
				itemstack:take_item()
 | 
									itemstack:take_item()
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
		-- call global on_use function with strength of 1
 | 
					 | 
				
			||||||
		bonemeal:on_use(pointed_thing.under, 1)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return itemstack
 | 
							return itemstack
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
@@ -524,13 +527,14 @@ minetest.register_craftitem("bonemeal:bonemeal", {
 | 
				
			|||||||
			return
 | 
								return
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							-- call global on_use function with strength of 2
 | 
				
			||||||
 | 
							if bonemeal:on_use(pointed_thing.under, 2) then
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			-- take item if not in creative
 | 
								-- take item if not in creative
 | 
				
			||||||
			if not bonemeal.is_creative(user:get_player_name()) then
 | 
								if not bonemeal.is_creative(user:get_player_name()) then
 | 
				
			||||||
				itemstack:take_item()
 | 
									itemstack:take_item()
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
		-- call global on_use function with strength of 2
 | 
					 | 
				
			||||||
		bonemeal:on_use(pointed_thing.under, 2)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return itemstack
 | 
							return itemstack
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
@@ -554,13 +558,14 @@ minetest.register_craftitem("bonemeal:fertiliser", {
 | 
				
			|||||||
			return
 | 
								return
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							-- call global on_use function with strength of 3
 | 
				
			||||||
 | 
							if bonemeal:on_use(pointed_thing.under, 3) then
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			-- take item if not in creative
 | 
								-- take item if not in creative
 | 
				
			||||||
			if not bonemeal.is_creative(user:get_player_name()) then
 | 
								if not bonemeal.is_creative(user:get_player_name()) then
 | 
				
			||||||
				itemstack:take_item()
 | 
									itemstack:take_item()
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
		-- call global on_use function with strength of 3
 | 
					 | 
				
			||||||
		bonemeal:on_use(pointed_thing.under, 3)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return itemstack
 | 
							return itemstack
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user