diff --git a/mods/HELP/mcl_tt/init.lua b/mods/HELP/mcl_tt/init.lua index 569dbe6866..9d01130404 100644 --- a/mods/HELP/mcl_tt/init.lua +++ b/mods/HELP/mcl_tt/init.lua @@ -1,103 +1,2 @@ -local S = minetest.get_translator("mcl_tt") - --- Armor -tt.register_snippet(function(itemstring) - local def = minetest.registered_items[itemstring] - local s = "" - local head = minetest.get_item_group(itemstring, "armor_head") - local torso = minetest.get_item_group(itemstring, "armor_torso") - local legs = minetest.get_item_group(itemstring, "armor_legs") - local feet = minetest.get_item_group(itemstring, "armor_feet") - if head > 0 then - s = s .. S("Head armor") - end - if torso > 0 then - s = s .. S("Torso armor") - end - if legs > 0 then - s = s .. S("Legs armor") - end - if feet > 0 then - s = s .. S("Feet armor") - end - if s == "" then - s = nil - end - return s -end) -tt.register_snippet(function(itemstring) - local def = minetest.registered_items[itemstring] - local s = "" - local use = minetest.get_item_group(itemstring, "mcl_armor_uses") - local pts = minetest.get_item_group(itemstring, "mcl_armor_points") - if pts > 0 then - s = s .. S("Armor points: @1", pts) - s = s .. "\n" - end - if use > 0 then - s = s .. S("Armor durability: @1", use) - end - if s == "" then - s = nil - end - return s -end) --- Horse armor -tt.register_snippet(function(itemstring) - local armor_g = minetest.get_item_group(itemstring, "horse_armor") - if armor_g and armor_g > 0 then - return S("Protection: @1%", 100 - armor_g) - end -end) - -tt.register_snippet(function(itemstring) - local def = minetest.registered_items[itemstring] - local s = "" - if def.groups.eatable and def.groups.eatable > 0 then - s = s .. S("Hunger points: +@1", def.groups.eatable) - end - if def._mcl_saturation and def._mcl_saturation > 0 then - if s ~= "" then - s = s .. "\n" - end - s = s .. S("Saturation points: +@1", string.format("%.1f", def._mcl_saturation)) - end - if s == "" then - s = nil - end - return s -end) - -tt.register_snippet(function(itemstring) - local def = minetest.registered_items[itemstring] - if minetest.get_item_group(itemstring, "crush_after_fall") == 1 then - return S("Deals damage when falling"), "#FFFF00" - end -end) - -tt.register_snippet(function(itemstring) - local def = minetest.registered_items[itemstring] - if def.groups.place_flowerlike == 1 then - return S("Grows on grass blocks or dirt") - elseif def.groups.place_flowerlike == 2 then - return S("Grows on grass blocks, podzol, dirt or coarse dirt") - end -end) - -tt.register_snippet(function(itemstring) - local def = minetest.registered_items[itemstring] - if def.groups.flammable then - return S("Flammable") - end -end) - -tt.register_snippet(function(itemstring) - if itemstring == "mcl_heads:zombie" then - return S("Zombie view range: -50%") - elseif itemstring == "mcl_heads:skeleton" then - return S("Skeleton view range: -50%") - elseif itemstring == "mcl_heads:creeper" then - return S("Creeper view range: -50%") - end -end) - +dofile(minetest.get_modpath("mcl_tt").."/snippets_base.lua") +dofile(minetest.get_modpath("mcl_tt").."/snippets_mcl.lua") diff --git a/mods/HELP/mcl_tt/locale/mcl_tt.de.tr b/mods/HELP/mcl_tt/locale/mcl_tt.de.tr index f793e59a05..8f878afc72 100644 --- a/mods/HELP/mcl_tt/locale/mcl_tt.de.tr +++ b/mods/HELP/mcl_tt/locale/mcl_tt.de.tr @@ -15,3 +15,33 @@ Flammable=Entzündlich Zombie view range: -50%=Zombiesichtweite: -50% Skeleton view range: -50%=Skelettsichtweite: -50% Creeper view range: -50%=Creepersichtweite: -50% +Damage: @1=Schaden: @1 +Damage (@1): @2=Schaden (@1): @2 +Healing: @1=Heilung: @1 +Healing (@1): @2=Heilung (@1): @2 +Full punch interval: @1s=Zeit zum Ausholen: @1s +Contact damage: @1 per second=Kontaktschaden: @1 pro Sekunde +Contact healing: @1 per second=Kontaktheilung: @1 pro Sekunde +Drowning damage: @1=Ertrinkensschaden: @1 +Bouncy (@1%)=Sprunghaft (@1%) +Luminance: @1=Lichtstärke: @1 +Slippery=Rutschig +Climbable=Erkletterbar +Climbable (only downwards)=Erkletterbar (nur nach unten) +No jumping=Kein Springen +No swimming upwards=Kein nach oben schwimmen +No rising=Kein Aufsteigen +Fall damage: @1%=Fallschaden: @1% +Fall damage: +@1%=Fallschaden: +@1% +No fall damage=Kein Fallschaden +Mining speed: @1=Grabegeschwindigkeit: @1 +Very fast=Sehr schnell +Extremely fast=Extrem schnell +Fast=Schnell +Slow=Langsam +Very slow=Sehr langsam +Painfully slow=Furchtbar langsam +Mining durability: @1=Grabehaltbarkeit: @1 +Block breaking strength: @1=Blockbruchstärke: @1 +@1 uses=@1 Verwendungen +Unlimited uses=Unbegrenzte Verwendungen diff --git a/mods/HELP/mcl_tt/locale/mcl_tt.fr.tr b/mods/HELP/mcl_tt/locale/mcl_tt.fr.tr index e3a9ec0b7c..a66311448b 100644 --- a/mods/HELP/mcl_tt/locale/mcl_tt.fr.tr +++ b/mods/HELP/mcl_tt/locale/mcl_tt.fr.tr @@ -15,3 +15,33 @@ Flammable=Inflammable Zombie view range: -50%=Distance de vue de Zombie: -50% Skeleton view range: -50%=Distance de vue de Squelette: -50% Creeper view range: -50%=Distance de vue de Creeper: -50% +Damage: @1=Dégâts: @1 +Damage (@1): @2=Dégâts (@1): @2 +Healing: @1=Guérison: @1 +Healing (@1): @2=Guérison (@1): @2 +Full punch interval: @1s=Intervalle de coup: @1s +Contact damage: @1 per second=Dégâts de contact: @1 par seconde +Contact healing: @1 per second=Guérison de contact: @1 par seconde +Drowning damage: @1=Dégâts de noyade: @1 +Bouncy (@1%)=Rebondissant (@1%) +Luminance: @1=Luminance: @1 +Slippery=Glissant +Climbable=Grimpable +Climbable (only downwards)=Grimpable (uniquement vers le bas) +No jumping=Ne pas sauter +No swimming upwards=Ne pas nager vers le haut +No rising=Pas de montée +Fall damage: @1%=Dégâts de chute: @1% +Fall damage: +@1%=Dégâts de chute: +@1% +No fall damage=Pas de dégâts de chute +Mining speed: @1=Vitesse de minage: @1 +Very fast=Très rapide +Extremely fast=Extremement rapide +Fast=Rapide +Slow=Lent +Very slow=Très lent +Painfully slow=Péniblement lent +Mining durability: @1=Durabilité de minage: @1 +Block breaking strength: @1=Résistance à la rupture: @1 +@1 uses=@1 utilisations +Unlimited uses=Utilisations illimitées diff --git a/mods/HELP/mcl_tt/locale/mcl_tt.ru.tr b/mods/HELP/mcl_tt/locale/mcl_tt.ru.tr index 657abc90ef..349b6a5fbb 100644 --- a/mods/HELP/mcl_tt/locale/mcl_tt.ru.tr +++ b/mods/HELP/mcl_tt/locale/mcl_tt.ru.tr @@ -15,3 +15,33 @@ Flammable=Легковоспламенимо Zombie view range: -50%=Дальность зрения зомби: -50% Skeleton view range: -50%=Дальность зрения скелета: -50% Creeper view range: -50%=Дальность зрения крипера: -50% +Damage: @1=Урон: @1 +Damage (@1): @2=Урон (@1): @2 +Healing: @1=Исцеление: @1 +Healing (@1): @2=Исцеление (@1): @2 +Full punch interval: @1s=Интервал полного удара: @1 с +Contact damage: @1 per second=Урон при контакте: @1 в секунду +Contact healing: @1 per second=Исцеление при контакте: @1 в секунду +Drowning damage: @1=Урон при падении: @1 +Bouncy (@1%)=Упругость (@1%) +Luminance: @1=Свечение: @1 +Slippery=Скользкость +Climbable=Можно карабкаться +Climbable (only downwards)=Можно спускаться +No jumping=Нельзя прыгать +No swimming upwards=Нельзя плыть вверх +No rising=Нельзя подниматься +Fall damage: @1%=Урон при падении: @1% +Fall damage: +@1%=Урон при падении: +@1% +No fall damage=Нет урона при падении +Mining speed: @1=Скорость добычи: @1 +Very fast=очень высокая +Extremely fast=ужасно высокая +Fast=высокая +Slow=низкая +Very slow=очень низкая +Painfully slow=мучительно низкая +Mining durability: @1=Долговечность добычи: @1 +Block breaking strength: @1=Сила разбиения блоков: @1 +@1 uses=@1 раз(а) +Unlimited uses=не ограничено diff --git a/mods/HELP/mcl_tt/locale/template.txt b/mods/HELP/mcl_tt/locale/template.txt index 357830bc07..1259216c76 100644 --- a/mods/HELP/mcl_tt/locale/template.txt +++ b/mods/HELP/mcl_tt/locale/template.txt @@ -15,3 +15,33 @@ Flammable= Zombie view range: -50%= Skeleton view range: -50%= Creeper view range: -50%= +Damage: @1= +Damage (@1): @2= +Healing: @1= +Healing (@1): @2= +Full punch interval: @1s= +Contact damage: @1 per second= +Contact healing: @1 per second= +Drowning damage: @1= +Bouncy (@1%)= +Luminance: @1= +Slippery= +Climbable= +Climbable (only downwards)= +No jumping= +No swimming upwards= +No rising= +Fall damage: @1%= +Fall damage: +@1%= +No fall damage= +Mining speed: @1= +Very fast= +Extremely fast= +Fast= +Slow= +Very slow= +Painfully slow= +Mining durability: @1= +Block breaking strength: @1= +@1 uses= +Unlimited uses= diff --git a/mods/HELP/tt/snippets_builtin.lua b/mods/HELP/mcl_tt/snippets_base.lua similarity index 99% rename from mods/HELP/tt/snippets_builtin.lua rename to mods/HELP/mcl_tt/snippets_base.lua index b61cc7ccca..376f00f2c9 100644 --- a/mods/HELP/tt/snippets_builtin.lua +++ b/mods/HELP/mcl_tt/snippets_base.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("tt") +local S = minetest.get_translator("mcl_tt") local function get_min_digtime(caps) local mintime diff --git a/mods/HELP/mcl_tt/snippets_mcl.lua b/mods/HELP/mcl_tt/snippets_mcl.lua new file mode 100644 index 0000000000..569dbe6866 --- /dev/null +++ b/mods/HELP/mcl_tt/snippets_mcl.lua @@ -0,0 +1,103 @@ +local S = minetest.get_translator("mcl_tt") + +-- Armor +tt.register_snippet(function(itemstring) + local def = minetest.registered_items[itemstring] + local s = "" + local head = minetest.get_item_group(itemstring, "armor_head") + local torso = minetest.get_item_group(itemstring, "armor_torso") + local legs = minetest.get_item_group(itemstring, "armor_legs") + local feet = minetest.get_item_group(itemstring, "armor_feet") + if head > 0 then + s = s .. S("Head armor") + end + if torso > 0 then + s = s .. S("Torso armor") + end + if legs > 0 then + s = s .. S("Legs armor") + end + if feet > 0 then + s = s .. S("Feet armor") + end + if s == "" then + s = nil + end + return s +end) +tt.register_snippet(function(itemstring) + local def = minetest.registered_items[itemstring] + local s = "" + local use = minetest.get_item_group(itemstring, "mcl_armor_uses") + local pts = minetest.get_item_group(itemstring, "mcl_armor_points") + if pts > 0 then + s = s .. S("Armor points: @1", pts) + s = s .. "\n" + end + if use > 0 then + s = s .. S("Armor durability: @1", use) + end + if s == "" then + s = nil + end + return s +end) +-- Horse armor +tt.register_snippet(function(itemstring) + local armor_g = minetest.get_item_group(itemstring, "horse_armor") + if armor_g and armor_g > 0 then + return S("Protection: @1%", 100 - armor_g) + end +end) + +tt.register_snippet(function(itemstring) + local def = minetest.registered_items[itemstring] + local s = "" + if def.groups.eatable and def.groups.eatable > 0 then + s = s .. S("Hunger points: +@1", def.groups.eatable) + end + if def._mcl_saturation and def._mcl_saturation > 0 then + if s ~= "" then + s = s .. "\n" + end + s = s .. S("Saturation points: +@1", string.format("%.1f", def._mcl_saturation)) + end + if s == "" then + s = nil + end + return s +end) + +tt.register_snippet(function(itemstring) + local def = minetest.registered_items[itemstring] + if minetest.get_item_group(itemstring, "crush_after_fall") == 1 then + return S("Deals damage when falling"), "#FFFF00" + end +end) + +tt.register_snippet(function(itemstring) + local def = minetest.registered_items[itemstring] + if def.groups.place_flowerlike == 1 then + return S("Grows on grass blocks or dirt") + elseif def.groups.place_flowerlike == 2 then + return S("Grows on grass blocks, podzol, dirt or coarse dirt") + end +end) + +tt.register_snippet(function(itemstring) + local def = minetest.registered_items[itemstring] + if def.groups.flammable then + return S("Flammable") + end +end) + +tt.register_snippet(function(itemstring) + if itemstring == "mcl_heads:zombie" then + return S("Zombie view range: -50%") + elseif itemstring == "mcl_heads:skeleton" then + return S("Skeleton view range: -50%") + elseif itemstring == "mcl_heads:creeper" then + return S("Creeper view range: -50%") + end +end) + diff --git a/mods/HELP/tt/API.md b/mods/HELP/tt/API.md index 0f24e472ce..a510553ce1 100644 --- a/mods/HELP/tt/API.md +++ b/mods/HELP/tt/API.md @@ -7,8 +7,6 @@ Add these to the item definition. * `_tt_ignore`: If `true`, the `description` of this item won't be altered at all * `_tt_help`: Custom help text -* `_tt_food`: If `true`, item is a food item that can be consumed by the player -* `_tt_food_hp`: Health increase (in HP) for player when consuming food item Once this mod had overwritten the `description` field of an item was overwritten, it will save the original (unaltered) `description` in the `_tt_original_description` field. diff --git a/mods/HELP/tt/README.md b/mods/HELP/tt/README.md index ca76902e47..f15599718a 100644 --- a/mods/HELP/tt/README.md +++ b/mods/HELP/tt/README.md @@ -1,12 +1,8 @@ # Extended Tooltip (`tt`) This mod extends the tooltip of items to add more informative texts. -It displays the following useful information: -* Weapon damage and speed -* Tool properties -* Noteworthy block properties -* Food satiation -* Custom help text (added by mods) +The mod itself does nothing and is meant to be integrated into +games to use the API to define custom tooltips (see `API.md`). ## License MIT License. diff --git a/mods/HELP/tt/init.lua b/mods/HELP/tt/init.lua index 1e639baee3..a79bf27b59 100644 --- a/mods/HELP/tt/init.lua +++ b/mods/HELP/tt/init.lua @@ -1,5 +1,3 @@ -local S = minetest.get_translator("tt") - tt = {} tt.COLOR_DEFAULT = "#d0ffd0" tt.COLOR_DANGER = "#ffff00" @@ -12,10 +10,7 @@ tt.register_snippet = function(func) table.insert(tt.registered_snippets, func) end --- Register core snippets - -dofile(minetest.get_modpath(minetest.get_current_modname()).."/snippets_core.lua") -dofile(minetest.get_modpath(minetest.get_current_modname()).."/snippets_builtin.lua") +dofile(minetest.get_modpath(minetest.get_current_modname()).."/snippets.lua") -- Apply item description updates diff --git a/mods/HELP/tt/locale/template.txt b/mods/HELP/tt/locale/template.txt deleted file mode 100644 index b5f11762f3..0000000000 --- a/mods/HELP/tt/locale/template.txt +++ /dev/null @@ -1,31 +0,0 @@ -# textdomain:tt -Damage: @1= -Damage (@1): @2= -Healing: @1= -Healing (@1): @2= -Full punch interval: @1s= -Contact damage: @1 per second= -Contact healing: @1 per second= -Drowning damage: @1= -Bouncy (@1%)= -Luminance: @1= -Slippery= -Climbable= -Climbable (only downwards)= -No jumping= -No swimming upwards= -No rising= -Fall damage: @1%= -Fall damage: +@1%= -No fall damage= -Mining speed: @1= -Very fast= -Extremely fast= -Fast= -Slow= -Very slow= -Painfully slow= -Mining durability: @1= -Block breaking strength: @1= -@1 uses= -Unlimited uses= diff --git a/mods/HELP/tt/locale/tt.de.tr b/mods/HELP/tt/locale/tt.de.tr deleted file mode 100644 index 508787de4a..0000000000 --- a/mods/HELP/tt/locale/tt.de.tr +++ /dev/null @@ -1,31 +0,0 @@ -# textdomain:tt -Damage: @1=Schaden: @1 -Damage (@1): @2=Schaden (@1): @2 -Healing: @1=Heilung: @1 -Healing (@1): @2=Heilung (@1): @2 -Full punch interval: @1s=Zeit zum Ausholen: @1s -Contact damage: @1 per second=Kontaktschaden: @1 pro Sekunde -Contact healing: @1 per second=Kontaktheilung: @1 pro Sekunde -Drowning damage: @1=Ertrinkensschaden: @1 -Bouncy (@1%)=Sprunghaft (@1%) -Luminance: @1=Lichtstärke: @1 -Slippery=Rutschig -Climbable=Erkletterbar -Climbable (only downwards)=Erkletterbar (nur nach unten) -No jumping=Kein Springen -No swimming upwards=Kein nach oben schwimmen -No rising=Kein Aufsteigen -Fall damage: @1%=Fallschaden: @1% -Fall damage: +@1%=Fallschaden: +@1% -No fall damage=Kein Fallschaden -Mining speed: @1=Grabegeschwindigkeit: @1 -Very fast=Sehr schnell -Extremely fast=Extrem schnell -Fast=Schnell -Slow=Langsam -Very slow=Sehr langsam -Painfully slow=Furchtbar langsam -Mining durability: @1=Grabehaltbarkeit: @1 -Block breaking strength: @1=Blockbruchstärke: @1 -@1 uses=@1 Verwendungen -Unlimited uses=Unbegrenzte Verwendungen diff --git a/mods/HELP/tt/locale/tt.fr.tr b/mods/HELP/tt/locale/tt.fr.tr deleted file mode 100644 index 70bc43ff41..0000000000 --- a/mods/HELP/tt/locale/tt.fr.tr +++ /dev/null @@ -1,31 +0,0 @@ -# textdomain:tt -Damage: @1=Dégâts: @1 -Damage (@1): @2=Dégâts (@1): @2 -Healing: @1=Guérison: @1 -Healing (@1): @2=Guérison (@1): @2 -Full punch interval: @1s=Intervalle de coup: @1s -Contact damage: @1 per second=Dégâts de contact: @1 par seconde -Contact healing: @1 per second=Guérison de contact: @1 par seconde -Drowning damage: @1=Dégâts de noyade: @1 -Bouncy (@1%)=Rebondissant (@1%) -Luminance: @1=Luminance: @1 -Slippery=Glissant -Climbable=Grimpable -Climbable (only downwards)=Grimpable (uniquement vers le bas) -No jumping=Ne pas sauter -No swimming upwards=Ne pas nager vers le haut -No rising=Pas de montée -Fall damage: @1%=Dégâts de chute: @1% -Fall damage: +@1%=Dégâts de chute: +@1% -No fall damage=Pas de dégâts de chute -Mining speed: @1=Vitesse de minage: @1 -Very fast=Très rapide -Extremely fast=Extremement rapide -Fast=Rapide -Slow=Lent -Very slow=Très lent -Painfully slow=Péniblement lent -Mining durability: @1=Durabilité de minage: @1 -Block breaking strength: @1=Résistance à la rupture: @1 -@1 uses=@1 utilisations -Unlimited uses=Utilisations illimitées diff --git a/mods/HELP/tt/locale/tt.ru.tr b/mods/HELP/tt/locale/tt.ru.tr deleted file mode 100644 index 6994bee603..0000000000 --- a/mods/HELP/tt/locale/tt.ru.tr +++ /dev/null @@ -1,31 +0,0 @@ -# textdomain:tt -Damage: @1=Урон: @1 -Damage (@1): @2=Урон (@1): @2 -Healing: @1=Исцеление: @1 -Healing (@1): @2=Исцеление (@1): @2 -Full punch interval: @1s=Интервал полного удара: @1 с -Contact damage: @1 per second=Урон при контакте: @1 в секунду -Contact healing: @1 per second=Исцеление при контакте: @1 в секунду -Drowning damage: @1=Урон при падении: @1 -Bouncy (@1%)=Упругость (@1%) -Luminance: @1=Свечение: @1 -Slippery=Скользкость -Climbable=Можно карабкаться -Climbable (only downwards)=Можно спускаться -No jumping=Нельзя прыгать -No swimming upwards=Нельзя плыть вверх -No rising=Нельзя подниматься -Fall damage: @1%=Урон при падении: @1% -Fall damage: +@1%=Урон при падении: +@1% -No fall damage=Нет урона при падении -Mining speed: @1=Скорость добычи: @1 -Very fast=очень высокая -Extremely fast=ужасно высокая -Fast=высокая -Slow=низкая -Very slow=очень низкая -Painfully slow=мучительно низкая -Mining durability: @1=Долговечность добычи: @1 -Block breaking strength: @1=Сила разбиения блоков: @1 -@1 uses=@1 раз(а) -Unlimited uses=не ограничено diff --git a/mods/HELP/tt/mod.conf b/mods/HELP/tt/mod.conf index aee1572f6b..d5c8c2eb1f 100644 --- a/mods/HELP/tt/mod.conf +++ b/mods/HELP/tt/mod.conf @@ -1,2 +1,2 @@ name = tt -description = Appends a helpful tooltip to the item description +description = Support for custom tooltip extensions for items diff --git a/mods/HELP/tt/snippets_core.lua b/mods/HELP/tt/snippets.lua similarity index 88% rename from mods/HELP/tt/snippets_core.lua rename to mods/HELP/tt/snippets.lua index cc67a10c91..694b225138 100644 --- a/mods/HELP/tt/snippets_core.lua +++ b/mods/HELP/tt/snippets.lua @@ -1,4 +1,4 @@ --- CORE SNIPPETS -- +-- CUSTOM SNIPPETS -- -- Custom text (_tt_help) tt.register_snippet(function(itemstring)