1 local S
= minetest
.get_translator("tt")
3 local function get_min_digtime(caps
)
6 if caps
.maxlevel
and caps
.maxlevel
> 1 then
11 local time
= caps
.times
[r
]
12 if caps
.maxlevel
and caps
.maxlevel
> 1 then
13 time
= time
/ caps
.maxlevel
15 if (not mintime
) or (time
and time
< mintime
) then
16 if time
and mintime
and (time
< mintime
) then
23 return mintime
, unique
28 -- Custom text (_tt_help)
29 tt
.register_snippet(function(itemstring
)
30 local def
= minetest
.registered_items
[itemstring
]
32 return def
._tt_help
, false
36 -- Tool information (digging times, weapon stats)
37 tt
.register_snippet(function(itemstring
)
38 local def
= minetest
.registered_items
[itemstring
]
40 if def
.tool_capabilities
then
44 if def
.tool_capabilities
.groupcaps
then
45 for group
, caps
in pairs(def
.tool_capabilities
.groupcaps
) do
46 local mintime
, unique_mintime
48 mintime
, unique_mintime
= get_min_digtime(caps
)
49 if mintime
and (mintime
> 0 and (not unique_mintime
)) then
50 d
= S("Digs @1 blocks", group
) .. "\n"
51 d
= d
.. S("Minimum dig time: @1s", string.format("%.2f", mintime
))
52 digs
= digs
.. "\n" .. d
53 elseif mintime
and mintime
== 0 then
54 d
= S("Digs @1 blocks instantly", group
)
55 digs
= digs
.. "\n" .. d
64 if def
.tool_capabilities
.damage_groups
then
65 for group
, damage
in pairs(def
.tool_capabilities
.damage_groups
) do
67 if group
== "fleshy" then
69 msg
= S("Damage: @1", damage
)
71 msg
= S("Healing: @1", math
.abs(damage
))
75 msg
= S("Damage (@1): @2", group
, damage
)
77 msg
= S("Healing (@1): @2", group
, math
.abs(damage
))
80 desc
= desc
.. "\n" .. msg
82 local full_punch_interval
= def
.tool_capabilities
.full_punch_interval
83 if not full_punch_interval
then
84 full_punch_interval
= 1
86 desc
= desc
.. "\n" .. S("Full punch interval: @1s", full_punch_interval
)
96 tt
.register_snippet(function(itemstring
)
97 local def
= minetest
.registered_items
[itemstring
]
100 desc
= S("Food item")
101 if def
._tt_food_hp
then
102 local msg
= S("+@1 food points", def
._tt_food_hp
)
103 desc
= desc
.. "\n" .. msg
110 tt
.register_snippet(function(itemstring
)
111 local def
= minetest
.registered_items
[itemstring
]
114 -- Health-related node facts
115 if def
.damage_per_second
then
116 if def
.damage_per_second
> 0 then
117 desc
= desc
.. "\n" .. minetest
.colorize(tt
.COLOR_DANGER
, S("Contact damage: @1 per second", def
.damage_per_second
))
118 elseif def
.damage_per_second
< 0 then
119 desc
= desc
.. "\n" .. minetest
.colorize(tt
.COLOR_GOOD
, S("Contact healing: @1 per second", math
.abs(def
.damage_per_second
)))
122 if def
.drowning
and def
.drowning
~= 0 then
123 desc
= desc
.. "\n" .. minetest
.colorize(tt
.COLOR_DANGER
, S("Drowning damage: @1", def
.drowning
))
125 local tmp
= minetest
.get_item_group(itemstring
, "fall_damage_add_percent")
127 desc
= desc
.. "\n" .. minetest
.colorize(tt
.COLOR_DANGER
, S("Fall damage: +@1%", tmp
))
128 elseif tmp
== -100 then
129 desc
= desc
.. "\n" .. minetest
.colorize(tt
.COLOR_GOOD
, S("No fall damage"))
131 desc
= desc
.. "\n" .. minetest
.colorize(tt
.COLOR_DEFAULT
, S("Fall damage: @1%", tmp
))
134 -- Movement-related node facts
135 if minetest
.get_item_group(itemstring
, "disable_jump") == 1 and not def
.climbable
then
136 if def
.liquidtype
== "none" then
137 desc
= desc
.. "\n" .. minetest
.colorize(tt
.COLOR_DEFAULT
, S("No jumping"))
139 desc
= desc
.. "\n" .. minetest
.colorize(tt
.COLOR_DEFAULT
, S("No swimming upwards"))
142 if def
.climbable
then
143 if minetest
.get_item_group(itemstring
, "disable_jump") == 1 then
144 desc
= desc
.. "\n" .. minetest
.colorize(tt
.COLOR_DEFAULT
, S("Climbable (only downwards)"))
146 desc
= desc
.. "\n" .. minetest
.colorize(tt
.COLOR_DEFAULT
, S("Climbable"))
149 if minetest
.get_item_group(itemstring
, "slippery") >= 1 then
150 desc
= desc
.. "\n" .. minetest
.colorize(tt
.COLOR_DEFAULT
, S("Slippery"))
152 local tmp
= minetest
.get_item_group(itemstring
, "bouncy")
154 desc
= desc
.. "\n" .. minetest
.colorize(tt
.COLOR_DEFAULT
, S("Bouncy (@1%)", tmp
))
158 tmp
= def
.light_source
159 if tmp
and tmp
>= 1 then
160 desc
= desc
.. "\n" .. minetest
.colorize(tt
.COLOR_DEFAULT
, S("Luminance: @1", tmp
))