forked from minetest-mods/unified_inventory
Show wear and description in crafting guide (#189)
This commit is contained in:
parent
8c84751ff8
commit
28a5d4db49
@ -157,7 +157,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
-- Check clicked item image button
|
-- Check clicked item image button
|
||||||
local clicked_item
|
local clicked_item
|
||||||
for name, value in pairs(fields) do
|
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
|
if new_dir and mangled_item then
|
||||||
clicked_item = unified_inventory.demangle_for_formspec(mangled_item)
|
clicked_item = unified_inventory.demangle_for_formspec(mangled_item)
|
||||||
if string.sub(clicked_item, 1, 6) == "group:" then
|
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 function stack_image_button(x, y, w, h, buttonname_prefix, item)
|
||||||
local name = item:get_name()
|
local name = item:get_name()
|
||||||
local count = item:get_count()
|
local count = item:get_count()
|
||||||
|
local wear = item:get_wear()
|
||||||
|
local description = item:get_meta():get_string("description")
|
||||||
local show_is_group = false
|
local show_is_group = false
|
||||||
local displayitem = name.." "..count
|
local displayitem = name.." "..count.." "..wear
|
||||||
local selectitem = name
|
local selectitem = name
|
||||||
if name:sub(1, 6) == "group:" then
|
if name:sub(1, 6) == "group:" then
|
||||||
local group_name = name:sub(7)
|
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
|
selectitem = group_item.sole and displayitem or name
|
||||||
end
|
end
|
||||||
local label = show_is_group and "G" or ""
|
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]",
|
local button = string.format("item_image_button[%f,%f;%f,%f;%s;%s;%s]",
|
||||||
x, y, w, h,
|
x, y, w, h,
|
||||||
F(displayitem), buttonname, label)
|
F(displayitem), buttonname, label)
|
||||||
@ -235,6 +239,8 @@ local function stack_image_button(x, y, w, h, buttonname_prefix, item)
|
|||||||
if andcount >= 1 then
|
if andcount >= 1 then
|
||||||
button = button .. string.format("tooltip[%s;%s]", buttonname, grouptip)
|
button = button .. string.format("tooltip[%s;%s]", buttonname, grouptip)
|
||||||
end
|
end
|
||||||
|
elseif description ~= "" then
|
||||||
|
button = button .. string.format("tooltip[%s;%s]", buttonname, F(description))
|
||||||
end
|
end
|
||||||
return button
|
return button
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user