summaryrefslogtreecommitdiff
path: root/register.lua
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2014-06-13 09:54:21 +0100
committerDiego Martinez <kaeza@users.sf.net>2014-06-13 06:28:38 -0300
commitdbf98cb694578223c0f3bb1016e054ce636f2276 (patch)
tree26e192261c35a04254e1032cf9a6181a9735540b /register.lua
parent7f4f0fd225f78ddde0c9c65bb1e2aa074c00949b (diff)
Fix display of group ingredients
Commit 043f6081452365daaa033c58e0738527ccb64c3d broke a couple of things in the course of its refactoring. This patch restores the "G" flag that signals group ingredients, the preference for "default:" items as group representatives (where a representative isn't specifically registered), and the built-in registration of default:cobble as representative for group:stone (because it's the most commonly-used item in that group).
Diffstat (limited to 'register.lua')
-rw-r--r--register.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/register.lua b/register.lua
index a471e2b..131cbe2 100644
--- a/register.lua
+++ b/register.lua
@@ -156,17 +156,17 @@ local function stack_image_button(x, y, w, h, buttonname_prefix, item)
if name:sub(1, 6) == "group:" then
local group_name = name:sub(7)
local group_item = unified_inventory.get_group_item(group_name)
- show_group = not group_item.sole
+ show_is_group = not group_item.sole
displayitem = group_item.item or "unknown"
selectitem = group_item.sole and displayitem or name
end
- -- Hackily shift the count to the bottom right
- local shiftstr = "\n\n "
+ local label = string.format("\n\n%s%7d", show_is_group and "G" or " ", count):gsub(" 1$", " .")
+ if label == "\n\n ." then label = "" end
return string.format("item_image_button[%u,%u;%u,%u;%s;%s;%s]",
x, y, w, h,
minetest.formspec_escape(displayitem),
minetest.formspec_escape(buttonname_prefix..selectitem),
- count ~= 1 and shiftstr..tostring(count) or "")
+ label)
end
unified_inventory.register_page("craftguide", {