mirror of
				https://github.com/minetest-mods/unified_inventory.git
				synced 2025-10-31 07:35:31 +01:00 
			
		
		
		
	Show wear and description in crafting guide (#189)
This commit is contained in:
		| @@ -157,7 +157,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) | ||||
| 	-- Check clicked item image button | ||||
| 	local clicked_item | ||||
| 	for name, value in pairs(fields) do | ||||
| 		local new_dir, mangled_item = string.match(name, "^item_button_([a-z]+)_(.*)$") | ||||
| 		local new_dir, mangled_item = string.match(name, "^[0-9]*_?item_button_([a-z]+)_(.*)$") | ||||
| 		if new_dir and mangled_item then | ||||
| 			clicked_item = unified_inventory.demangle_for_formspec(mangled_item) | ||||
| 			if string.sub(clicked_item, 1, 6) == "group:" then | ||||
|   | ||||
							
								
								
									
										10
									
								
								register.lua
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								register.lua
									
									
									
									
									
								
							| @@ -208,8 +208,10 @@ ui.register_page("craft", { | ||||
| local function stack_image_button(x, y, w, h, buttonname_prefix, item) | ||||
| 	local name = item:get_name() | ||||
| 	local count = item:get_count() | ||||
| 	local wear = item:get_wear() | ||||
| 	local description = item:get_meta():get_string("description") | ||||
| 	local show_is_group = false | ||||
| 	local displayitem = name.." "..count | ||||
| 	local displayitem = name.." "..count.." "..wear | ||||
| 	local selectitem = name | ||||
| 	if name:sub(1, 6) == "group:" then | ||||
| 		local group_name = name:sub(7) | ||||
| @@ -219,7 +221,9 @@ local function stack_image_button(x, y, w, h, buttonname_prefix, item) | ||||
| 		selectitem = group_item.sole and displayitem or name | ||||
| 	end | ||||
| 	local label = show_is_group and "G" or "" | ||||
| 	local buttonname = F(buttonname_prefix..ui.mangle_for_formspec(selectitem)) | ||||
| 	-- Unique id to prevent tooltip being overridden | ||||
| 	local id = string.format("%i%i_", x*10, y*10) | ||||
| 	local buttonname = F(id..buttonname_prefix..ui.mangle_for_formspec(selectitem)) | ||||
| 	local button = string.format("item_image_button[%f,%f;%f,%f;%s;%s;%s]", | ||||
| 			x, y, w, h, | ||||
| 			F(displayitem), buttonname, label) | ||||
| @@ -235,6 +239,8 @@ local function stack_image_button(x, y, w, h, buttonname_prefix, item) | ||||
| 		if andcount >= 1 then | ||||
| 			button = button  .. string.format("tooltip[%s;%s]", buttonname, grouptip) | ||||
| 		end | ||||
| 	elseif description ~= "" then | ||||
| 		button = button  .. string.format("tooltip[%s;%s]", buttonname, F(description)) | ||||
| 	end | ||||
| 	return button | ||||
| end | ||||
|   | ||||
		Reference in New Issue
	
	Block a user