Skip to content

Commit

Permalink
Tooltips: add lord-like damage desc. Closes #1584. Relates to #1587
Browse files Browse the repository at this point in the history
  • Loading branch information
alek13 committed Jul 31, 2024
1 parent 6d1da01 commit 2e96013
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 16 deletions.
11 changes: 11 additions & 0 deletions mods/lord/Player/Help/lord_tooltips/locale/lord_tooltips.en.tr
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# textdomain: lord_tooltips

Properties=Properties
Damage=Damage
Defense=Defense
Effects=Effects

# Properties / Digging
crumbly=crumbly
cracky=cracky
snappy=snappy
choppy=choppy
fleshy=fleshy
explody=explody

# Damages
$dmg-item-tpl$ @1: @2 in @3 sec @4=@1: @2 in @3 sec @4
(@1/sec)=(@1/сек)
Punch Speed: @1=Punch Speed: @1
fleshy_dmg=fleshy
soulful_dmg=soulful
11 changes: 11 additions & 0 deletions mods/lord/Player/Help/lord_tooltips/locale/lord_tooltips.ru.tr
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# textdomain: lord_tooltips

Properties=Свойства
Damage=Урон
Defense=Защита
Effects=Эффекты

# Properties / Digging
crumbly=сыпучий
cracky=разламывающийся
snappy=непрочный
choppy=рубящийся
fleshy=живой/прокалываемый
explody=взрывающийся

# Damages
$dmg-item-tpl$ @1: @2 in @3 sec @4=@1: @2 в @3 сек @4
(@1/sec)=(@1/сек)
Punch Speed: @1=Скорость удара: @1
fleshy_dmg=телесный
soulful_dmg=душ
11 changes: 11 additions & 0 deletions mods/lord/Player/Help/lord_tooltips/locale/template.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# textdomain: lord_tooltips

Properties=
Damage=
Defense=
Effects=

# Properties / Digging
crumbly=
cracky=
snappy=
choppy=
fleshy=
explody=

# Damages
$dmg-item-tpl$ @1: @2 in @3 sec @4=@1: @2 in @3 sec @4
(@1/sec)=(@1/sec)
Punch Speed: @1=
fleshy_dmg=
soulful_dmg=
59 changes: 43 additions & 16 deletions mods/lord/Player/Help/lord_tooltips/src/lord_tooltips.lua
Original file line number Diff line number Diff line change
@@ -1,34 +1,61 @@
local items, colorize
= minetest.registered_items, minetest.colorize
local items, colorize
= minetest.registered_items, minetest.colorize

local S = minetest.get_translator(minetest.get_current_modname())


local properties = {
"crumbly", "cracky", "snappy", "choppy", "fleshy", "explody",
'crumbly', 'cracky', 'snappy', 'choppy', 'fleshy', 'explody',
}


local function register_properties_snippet()
tt.register_snippet(function(itemstring)
local groups = items[itemstring].groups
--- @param item_string string
--- @return string|nil
local function properties_snippet(item_string)
local groups = items[item_string].groups

local prop_strings = {}
for _, property in pairs(properties) do
if table.has_key(groups, property) then
prop_strings[#prop_strings+1] = "" .. colorize("#aaa", S(property)) .. ": " .. groups[property]
end
local prop_strings = {}
for _, property in pairs(properties) do
if table.has_key(groups, property) then
prop_strings[#prop_strings+1] = '' .. colorize('#bbb', S(property)) .. ': ' .. groups[property]
end
end

return #prop_strings ~= 0
and (colorize("#ee8", "\n" .. S("Properties")) .. ":\n" .. table.concat(prop_strings, "\n"))
or nil
end)
return #prop_strings ~= 0
and (colorize('#ee8', '\n' .. S('Properties')) .. ':\n' .. table.concat(prop_strings, '\n'))
or nil
end

--- @param item_string string
--- @return string|nil
local function damage_snippet(item_string)
local tool_capabilities = items[item_string].tool_capabilities
if not tool_capabilities or not tool_capabilities.damage_groups then return nil end

local interval = tool_capabilities.full_punch_interval or 1
local damage_strings = {}
for type, damage in pairs(tool_capabilities.damage_groups) do
local damage_in_sec = damage / interval
local list_item = S(
'$dmg-item-tpl$ @1: @2 in @3 sec @4',
colorize('#bbb', S(type..'_dmg')), damage, interval, colorize('#ddd', S('(@1/sec)', damage_in_sec))
)
damage_strings[#damage_strings+1] = '' .. list_item
end

return #damage_strings ~=0
and (
'\n' .. colorize('#ee8', S('Damage')) .. ':\n' ..
table.concat(damage_strings, '\n') .. '\n' ..
S('Punch Speed: @1', interval)
)
or nil
end


return {
init = function()
register_properties_snippet()
tt.register_snippet(properties_snippet)
tt.register_snippet(damage_snippet)
end,
}

0 comments on commit 2e96013

Please sign in to comment.