forked from minetest-mods/item_drop
		
	Tidy up pickup_particle code
This commit is contained in:
		
							
								
								
									
										54
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										54
									
								
								init.lua
									
									
									
									
									
								
							| @@ -38,6 +38,19 @@ minetest.settings:get_bool("enable_item_pickup") ~= false then | |||||||
| 		error"zero velocity mode can't be used together with magnet mode" | 		error"zero velocity mode can't be used together with magnet mode" | ||||||
| 	end | 	end | ||||||
|  |  | ||||||
|  | 	-- tells whether an inventorycube should be shown as pickup_particle or not | ||||||
|  | 	-- for known drawtypes | ||||||
|  | 	local inventorycube_drawtypes = { | ||||||
|  | 		normal = true, | ||||||
|  | 		allfaces = true, | ||||||
|  | 		allfaces_optional = true, | ||||||
|  | 		glasslike = true, | ||||||
|  | 		glasslike_framed = true, | ||||||
|  | 		glasslike_framed_optional = true, | ||||||
|  | 		liquid = true, | ||||||
|  | 		flowingliquid = true, | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	-- adds the item to the inventory and removes the object | 	-- adds the item to the inventory and removes the object | ||||||
| 	local function collect_item(ent, pos, player) | 	local function collect_item(ent, pos, player) | ||||||
| 		minetest.sound_play("item_drop_pickup", { | 		minetest.sound_play("item_drop_pickup", { | ||||||
| @@ -45,30 +58,29 @@ minetest.settings:get_bool("enable_item_pickup") ~= false then | |||||||
| 			gain = pickup_gain, | 			gain = pickup_gain, | ||||||
| 		}) | 		}) | ||||||
| 		if pickup_particle then | 		if pickup_particle then | ||||||
| 			local item = minetest.registered_nodes[ent.itemstring:gsub("(.*)%s.*$","%1")] | 			local item = minetest.registered_nodes[ | ||||||
|  | 				ent.itemstring:gsub("(.*)%s.*$", "%1")] | ||||||
| 			local image = "" | 			local image = "" | ||||||
| 			if item and minetest.registered_items[item.name] and minetest.registered_items[item.name].tiles then | 			if item and item.tiles and item.tiles[1] then | ||||||
| 				if minetest.registered_items[item.name].tiles[1] then | 				if inventorycube_drawtypes[item.drawtype] then | ||||||
| 						local dt = minetest.registered_items[item.name].drawtype | 					local tiles = item.tiles | ||||||
| 						if dt == "normal" or dt == "allfaces" or dt == "allfaces_optional" |  | ||||||
| 						or dt == "glasslike" or dt =="glasslike_framed" or dt == "glasslike_framed_optional" |  | ||||||
| 						or dt == "liquid" or dt == "flowingliquid" then |  | ||||||
| 							local tiles = minetest.registered_items[item.name].tiles |  | ||||||
|  |  | ||||||
| 							local top = tiles[1] | 					local top = tiles[1] | ||||||
| 							if (type(top) == "table") then top = top.item end | 					if type(top) == "table" then | ||||||
| 							local left = tiles[3] | 						top = top.item | ||||||
| 							if not left then left = top end | 					end | ||||||
| 							if (type(left) == "table") then left = left.item end | 					local left = tiles[3] or top | ||||||
| 							local right = tiles[5] | 					if type(left) == "table" then | ||||||
| 							if not right then right = left end | 						left = left.item | ||||||
| 							if (type(right) == "table") then right = right.item end | 					end | ||||||
|  | 					local right = tiles[5] or left | ||||||
|  | 					if type(right) == "table" then | ||||||
|  | 						right = right.item | ||||||
|  | 					end | ||||||
|  |  | ||||||
| 							image = minetest.inventorycube(top, left, right) | 					image = minetest.inventorycube(top, left, right) | ||||||
| 						else | 				else | ||||||
| 							image = minetest.registered_items[item.name].inventory_image | 					image = item.inventory_image or item.tiles[1] | ||||||
| 							if not image then image = minetest.registered_items[item.name].tiles[1] end |  | ||||||
| 						end |  | ||||||
| 				end | 				end | ||||||
| 				minetest.add_particle({ | 				minetest.add_particle({ | ||||||
| 					pos = {x = pos.x, y = pos.y + 1.5, z = pos.z}, | 					pos = {x = pos.x, y = pos.y + 1.5, z = pos.z}, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user