Add item tooltips with mod name

Inspired by #118, @Quent42340
This commit is contained in:
SmallJoker 2018-12-12 20:18:53 +01:00
parent 77c3de08ce
commit 54abad72f0
1 changed files with 14 additions and 7 deletions

View File

@ -223,7 +223,8 @@ function unified_inventory.get_formspec(player, page)
for y = 0, ui_peruser.pagerows - 1 do
for x = 0, ui_peruser.pagecols - 1 do
local name = unified_inventory.filtered_items_list[player_name][list_index]
if minetest.registered_items[name] then
local item = minetest.registered_items[name]
if item then
-- Clicked on current item: Flip crafting direction
if name == unified_inventory.current_item[player_name] then
local cdir = unified_inventory.current_craft_direction[player_name]
@ -236,12 +237,18 @@ function unified_inventory.get_formspec(player, page)
-- Default: use active search direction by default
dir = unified_inventory.active_search_direction[player_name]
end
formspec[n] = "item_image_button["
..(8.2 + x * 0.7)..","
..(ui_peruser.formspec_y + ui_peruser.page_y + y * 0.7)..";.81,.81;"
..name..";item_button_"..dir.."_"
..unified_inventory.mangle_for_formspec(name)..";]"
n = n+1
local button_name = "item_button_" .. dir .. "_"
.. unified_inventory.mangle_for_formspec(name)
formspec[n] = ("item_image_button[%f,%f;.81,.81;%s;%s;]"):format(
8.2 + x * 0.7, ui_peruser.formspec_y + ui_peruser.page_y + y * 0.7,
name, button_name
)
formspec[n + 1] = ("tooltip[%s;%s \\[%s\\]]"):format(
button_name, minetest.formspec_escape(item.description),
item.mod_origin or "??"
)
n = n + 2
list_index = list_index + 1
end
end