Show meta descriptions in crafting guide

This commit is contained in:
Jean-Patrick Guerrero 2021-04-10 01:36:37 +02:00
parent eed43032bc
commit 3f6aa287d9
2 changed files with 39 additions and 25 deletions

View File

@ -1308,7 +1308,7 @@ local function get_tooltip(item, info)
tooltip = S("Any item belonging to the groups: @1", groupstr) tooltip = S("Any item belonging to the groups: @1", groupstr)
end end
else else
tooltip = get_desc(item) tooltip = info.meta_desc or get_desc(item)
end end
local function add(str) local function add(str)
@ -1400,8 +1400,8 @@ local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_siz
if rcp.type == "fuel" then if rcp.type == "fuel" then
fs("animated_image", X + 0.05, Y, ITEM_BTN_SIZE, ITEM_BTN_SIZE, PNG.fire_anim, 8, 180) fs("animated_image", X + 0.05, Y, ITEM_BTN_SIZE, ITEM_BTN_SIZE, PNG.fire_anim, 8, 180)
else else
local item = rcp.output local item = ItemStack(rcp.output)
item = ItemStack(clean_name(item)) local meta = item:get_meta()
local name = item:get_name() local name = item:get_name()
local count = item:get_count() local count = item:get_count()
local bt_s = ITEM_BTN_SIZE * 1.2 local bt_s = ITEM_BTN_SIZE * 1.2
@ -1421,6 +1421,10 @@ local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_siz
local weird = name ~= "" and desc and weird_desc(desc) or nil local weird = name ~= "" and desc and weird_desc(desc) or nil
local burntime = fuel_cache[name] and fuel_cache[name].burntime local burntime = fuel_cache[name] and fuel_cache[name].burntime
local short_desc = meta:get_string("short_description")
local long_desc = meta:get_string("description")
local meta_desc = (short_desc ~= "" and short_desc) or (long_desc ~= "" and long_desc)
local infos = { local infos = {
unknown = unknown, unknown = unknown,
weird = weird, weird = weird,
@ -1428,6 +1432,7 @@ local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_siz
repair = repairable(name), repair = repairable(name),
rarity = rcp.rarity, rarity = rcp.rarity,
tools = rcp.tools, tools = rcp.tools,
meta_desc = meta_desc,
} }
if next(infos) then if next(infos) then
@ -1457,8 +1462,8 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
end end
for i = 1, width * rows do for i = 1, width * rows do
local item = rcp.items[i] or "" local _item = rcp.items[i] or ""
item = clean_name(item) local item = clean_name(_item)
local name = match(item, "%S*") local name = match(item, "%S*")
local X = ceil((i - 1) % width - width) local X = ceil((i - 1) % width - width)
@ -1530,6 +1535,11 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
local weird = name ~= "" and desc and weird_desc(desc) or nil local weird = name ~= "" and desc and weird_desc(desc) or nil
local burntime = fuel_cache[name] and fuel_cache[name].burntime local burntime = fuel_cache[name] and fuel_cache[name].burntime
local meta = ItemStack(_item):get_meta()
local short_desc = meta:get_string("short_description")
local long_desc = meta:get_string("description")
local meta_desc = (short_desc ~= "" and short_desc) or (long_desc ~= "" and long_desc)
local infos = { local infos = {
unknown = unknown, unknown = unknown,
weird = weird, weird = weird,
@ -1537,6 +1547,7 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
burntime = burntime, burntime = burntime,
cooktime = cooktime, cooktime = cooktime,
replace = replace, replace = replace,
meta_desc = meta_desc,
} }
if next(infos) then if next(infos) then

View File

@ -1,17 +1,20 @@
local mt = ItemStack("default:wood")
mt:get_meta():set_string("description", "test wood")
mt:get_meta():set_string("color", "#000")
local mt2 = ItemStack("dye:red")
mt2:get_meta():set_string("description", "test red")
mt2:get_meta():set_string("color", "#ff0")
minetest.register_craft({ minetest.register_craft({
output = minetest.itemstring_with_palette("default:wood", 3), output = mt:to_string(),
type = "shapeless", type = "shapeless",
recipe = { recipe = {
"default:wood", "default:wood",
"dye:red", mt2:to_string(),
}, },
}) })
i3.register_craft({
result = "default:ladder_wood",
items = {"default:copper_ingot 7, default:tin_ingot, default:steel_ingot 2"},
})
i3.register_craft({ i3.register_craft({
grid = { grid = {
"X #", "X #",