From b19981b419d1ccaa4ec6bc37755804a5d09f36d5 Mon Sep 17 00:00:00 2001 From: alek13 Date: Wed, 3 Jul 2024 14:49:10 +0300 Subject: [PATCH] Extended Tooltips: add properties description. Closes #1490 --- .luacheckrc | 4 +-- mods/lord/Player/Help/lord_tooltips/init.lua | 10 ++++++ .../lord_tooltips/locale/lord_tooltips.en.tr | 10 ++++++ .../lord_tooltips/locale/lord_tooltips.ru.tr | 10 ++++++ .../Help/lord_tooltips/locale/template.txt | 10 ++++++ mods/lord/Player/Help/lord_tooltips/mod.conf | 2 ++ .../Help/lord_tooltips/src/lord_tooltips.lua | 34 +++++++++++++++++++ mods/lord/Player/Help/modpack.conf | 1 + 8 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 mods/lord/Player/Help/lord_tooltips/init.lua create mode 100644 mods/lord/Player/Help/lord_tooltips/locale/lord_tooltips.en.tr create mode 100644 mods/lord/Player/Help/lord_tooltips/locale/lord_tooltips.ru.tr create mode 100644 mods/lord/Player/Help/lord_tooltips/locale/template.txt create mode 100644 mods/lord/Player/Help/lord_tooltips/mod.conf create mode 100644 mods/lord/Player/Help/lord_tooltips/src/lord_tooltips.lua create mode 100644 mods/lord/Player/Help/modpack.conf diff --git a/.luacheckrc b/.luacheckrc index fcf013e75..767773fb6 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -10,8 +10,8 @@ globals = { "default", "doors", "farming", "player_api", "sethome.set", "beds", - -- Other APIs - "hbhunger", + -- Other APIs (mods/_various) + "hbhunger", "tt" } read_globals = { diff --git a/mods/lord/Player/Help/lord_tooltips/init.lua b/mods/lord/Player/Help/lord_tooltips/init.lua new file mode 100644 index 000000000..409fc69ac --- /dev/null +++ b/mods/lord/Player/Help/lord_tooltips/init.lua @@ -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 diff --git a/mods/lord/Player/Help/lord_tooltips/locale/lord_tooltips.en.tr b/mods/lord/Player/Help/lord_tooltips/locale/lord_tooltips.en.tr new file mode 100644 index 000000000..75afd3071 --- /dev/null +++ b/mods/lord/Player/Help/lord_tooltips/locale/lord_tooltips.en.tr @@ -0,0 +1,10 @@ +# textdomain: lord_tooltips + +Properties=Properties + +crumbly=crumbly +cracky=cracky +snappy=snappy +choppy=choppy +fleshy=fleshy +explody=explody diff --git a/mods/lord/Player/Help/lord_tooltips/locale/lord_tooltips.ru.tr b/mods/lord/Player/Help/lord_tooltips/locale/lord_tooltips.ru.tr new file mode 100644 index 000000000..501aaf503 --- /dev/null +++ b/mods/lord/Player/Help/lord_tooltips/locale/lord_tooltips.ru.tr @@ -0,0 +1,10 @@ +# textdomain: lord_tooltips + +Properties=Свойства + +crumbly=сыпучий +cracky=разламывающийся +snappy=непрочный +choppy=рубящийся +fleshy=живой/прокалываемый +explody=взрывающийся diff --git a/mods/lord/Player/Help/lord_tooltips/locale/template.txt b/mods/lord/Player/Help/lord_tooltips/locale/template.txt new file mode 100644 index 000000000..e631c8b3a --- /dev/null +++ b/mods/lord/Player/Help/lord_tooltips/locale/template.txt @@ -0,0 +1,10 @@ +# textdomain: lord_tooltips + +Properties= + +crumbly= +cracky= +snappy= +choppy= +fleshy= +explody= diff --git a/mods/lord/Player/Help/lord_tooltips/mod.conf b/mods/lord/Player/Help/lord_tooltips/mod.conf new file mode 100644 index 000000000..b926c8d7c --- /dev/null +++ b/mods/lord/Player/Help/lord_tooltips/mod.conf @@ -0,0 +1,2 @@ +name = lord_tooltips +depends = tt diff --git a/mods/lord/Player/Help/lord_tooltips/src/lord_tooltips.lua b/mods/lord/Player/Help/lord_tooltips/src/lord_tooltips.lua new file mode 100644 index 000000000..ae94a44c0 --- /dev/null +++ b/mods/lord/Player/Help/lord_tooltips/src/lord_tooltips.lua @@ -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, +} diff --git a/mods/lord/Player/Help/modpack.conf b/mods/lord/Player/Help/modpack.conf new file mode 100644 index 000000000..b1d64bd1f --- /dev/null +++ b/mods/lord/Player/Help/modpack.conf @@ -0,0 +1 @@ +name = Player_Help