-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tooltips: add Durability info. Relates to #1602
- Loading branch information
Showing
5 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
mods/lord/Player/Help/lord_tooltips/src/snippet/durability.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
local items, colorize | ||
= minetest.registered_items, minetest.colorize | ||
|
||
local S = minetest.get_mod_translator() | ||
|
||
|
||
|
||
|
||
--- @param item_string string | ||
--- @return string|nil | ||
return function(item_string) | ||
local tool_capabilities = items[item_string].tool_capabilities | ||
if not tool_capabilities or not tool_capabilities.groupcaps then return nil end | ||
|
||
local strength_strings = {} | ||
for group, caps in pairs(tool_capabilities.groupcaps) do | ||
if caps.uses then | ||
local list_item = S('@1: @2', colorize('#bbb', S(group)), caps.uses) | ||
strength_strings[#strength_strings + 1] = ' • ' .. list_item | ||
end | ||
end | ||
|
||
return #strength_strings ~= 0 | ||
and ('\n' .. | ||
colorize('#ee8', S('Durability')) .. ':\n' .. | ||
table.concat(strength_strings, '\n') | ||
) | ||
or nil | ||
end |