Skip to content

Commit

Permalink
Extended Tooltips: add properties description. Closes #1490
Browse files Browse the repository at this point in the history
  • Loading branch information
alek13 committed Jul 3, 2024
1 parent e4d45d1 commit b19981b
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ globals = {
"default", "doors", "farming", "player_api",
"sethome.set", "beds",

-- Other APIs
"hbhunger",
-- Other APIs (mods/_various)
"hbhunger", "tt"
}

read_globals = {
Expand Down
10 changes: 10 additions & 0 deletions mods/lord/Player/Help/lord_tooltips/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
local DS = os.DIRECTORY_SEPARATOR
local mod_path = minetest.get_modpath(minetest.get_current_modname())
local old_require = require
require = function(name) return dofile(mod_path .. DS .. "src" .. DS .. name:gsub("%.", DS) .. ".lua") end


require("lord_tooltips").init()


require = old_require
10 changes: 10 additions & 0 deletions mods/lord/Player/Help/lord_tooltips/locale/lord_tooltips.en.tr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# textdomain: lord_tooltips

Properties=Properties

crumbly=crumbly
cracky=cracky
snappy=snappy
choppy=choppy
fleshy=fleshy
explody=explody
10 changes: 10 additions & 0 deletions mods/lord/Player/Help/lord_tooltips/locale/lord_tooltips.ru.tr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# textdomain: lord_tooltips

Properties=Свойства

crumbly=сыпучий
cracky=разламывающийся
snappy=непрочный
choppy=рубящийся
fleshy=живой/прокалываемый
explody=взрывающийся
10 changes: 10 additions & 0 deletions mods/lord/Player/Help/lord_tooltips/locale/template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# textdomain: lord_tooltips

Properties=

crumbly=
cracky=
snappy=
choppy=
fleshy=
explody=
2 changes: 2 additions & 0 deletions mods/lord/Player/Help/lord_tooltips/mod.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name = lord_tooltips
depends = tt
34 changes: 34 additions & 0 deletions mods/lord/Player/Help/lord_tooltips/src/lord_tooltips.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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",
}


local function register_properties_snippet()
tt.register_snippet(function(itemstring)
local groups = items[itemstring].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
end

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


return {
init = function()
register_properties_snippet()
end,
}
1 change: 1 addition & 0 deletions mods/lord/Player/Help/modpack.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name = Player_Help

0 comments on commit b19981b

Please sign in to comment.