1
0
Fork 0

Use pure-API version of tt mod

objects
Wuzzy 2020-09-10 15:34:53 +02:00
parent daede2a183
commit b47ff2b9be
16 changed files with 231 additions and 244 deletions

View File

@ -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")

View File

@ -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

View File

@ -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

View File

@ -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=не ограничено

View File

@ -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=

View File

@ -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

View File

@ -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)

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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=

View File

@ -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

View File

@ -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

View File

@ -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=не ограничено

View File

@ -1,2 +1,2 @@
name = tt
description = Appends a helpful tooltip to the item description
description = Support for custom tooltip extensions for items

View File

@ -1,4 +1,4 @@
-- CORE SNIPPETS --
-- CUSTOM SNIPPETS --
-- Custom text (_tt_help)
tt.register_snippet(function(itemstring)