1 local S
= minetest
.get_translator("tt_base")
3 local function get_min_digtime(caps
)
6 local maxlevel
= caps
.maxlevel
15 local time
= caps
.times
[r
]
16 if time
and maxlevel
> 1 then
17 time
= time
/ maxlevel
19 if time
and ((not mintime
) or (time
< mintime
)) then
20 if mintime
and (time
< mintime
) then
27 return mintime
, unique
30 local function newline(str
)
37 -- Tool information (digging times, weapon stats)
38 tt
.register_snippet(function(itemstring
)
39 local def
= minetest
.registered_items
[itemstring
]
41 if def
.tool_capabilities
then
45 if def
.tool_capabilities
.groupcaps
then
46 for group
, caps
in pairs(def
.tool_capabilities
.groupcaps
) do
47 local mintime
, unique_mintime
49 mintime
, unique_mintime
= get_min_digtime(caps
)
50 if mintime
and (mintime
> 0 or (not unique_mintime
)) then
51 d
= S("Digs @1 blocks", group
) .. "\n"
52 d
= d
.. S("Minimum dig time: @1s", string.format("%.2f", mintime
))
55 elseif mintime
and mintime
== 0 then
56 d
= S("Digs @1 blocks instantly", group
)
67 if def
.tool_capabilities
.damage_groups
then
68 for group
, damage
in pairs(def
.tool_capabilities
.damage_groups
) do
70 if group
== "fleshy" then
72 msg
= S("Damage: @1", damage
)
74 msg
= S("Healing: @1", math
.abs(damage
))
78 msg
= S("Damage (@1): @2", group
, damage
)
80 msg
= S("Healing (@1): @2", group
, math
.abs(damage
))
86 local full_punch_interval
= def
.tool_capabilities
.full_punch_interval
87 if not full_punch_interval
then
88 full_punch_interval
= 1
91 desc
= desc
.. S("Full punch interval: @1s", string.format("%.2f", full_punch_interval
))
101 tt
.register_snippet(function(itemstring
)
102 local def
= minetest
.registered_items
[itemstring
]
105 desc
= S("Food item")
106 if def
._tt_food_hp
then
107 local msg
= S("+@1 food points", def
._tt_food_hp
)
108 desc
= desc
.. "\n" .. msg
115 tt
.register_snippet(function(itemstring
)
116 local def
= minetest
.registered_items
[itemstring
]
119 -- Health-related node facts
120 if def
.damage_per_second
then
121 if def
.damage_per_second
> 0 then
123 desc
= desc
.. minetest
.colorize(tt
.COLOR_DANGER
, S("Contact damage: @1 per second", def
.damage_per_second
))
124 elseif def
.damage_per_second
< 0 then
126 desc
= desc
.. minetest
.colorize(tt
.COLOR_GOOD
, S("Contact healing: @1 per second", math
.abs(def
.damage_per_second
)))
129 if def
.drowning
and def
.drowning
~= 0 then
131 desc
= desc
.. minetest
.colorize(tt
.COLOR_DANGER
, S("Drowning damage: @1", def
.drowning
))
133 local tmp
= minetest
.get_item_group(itemstring
, "fall_damage_add_percent")
136 desc
= desc
.. minetest
.colorize(tt
.COLOR_DANGER
, S("Fall damage: +@1%", tmp
))
137 elseif tmp
== -100 then
139 desc
= desc
.. minetest
.colorize(tt
.COLOR_GOOD
, S("No fall damage"))
142 desc
= desc
.. minetest
.colorize(tt
.COLOR_DEFAULT
, S("Fall damage: @1%", tmp
))
145 -- Movement-related node facts
146 if minetest
.get_item_group(itemstring
, "disable_jump") == 1 and not def
.climbable
then
147 if def
.liquidtype
== "none" then
149 desc
= desc
.. minetest
.colorize(tt
.COLOR_DEFAULT
, S("No jumping"))
150 elseif minetest
.get_item_group(itemstring
, "fake_liquid") == 0 then
152 desc
= desc
.. minetest
.colorize(tt
.COLOR_DEFAULT
, S("No swimming upwards"))
155 desc
= desc
.. minetest
.colorize(tt
.COLOR_DEFAULT
, S("No rising"))
158 if def
.climbable
then
159 if minetest
.get_item_group(itemstring
, "disable_jump") == 1 then
161 desc
= desc
.. minetest
.colorize(tt
.COLOR_DEFAULT
, S("Climbable (only downwards)"))
164 desc
= desc
.. minetest
.colorize(tt
.COLOR_DEFAULT
, S("Climbable"))
167 if minetest
.get_item_group(itemstring
, "slippery") >= 1 then
169 desc
= desc
.. minetest
.colorize(tt
.COLOR_DEFAULT
, S("Slippery"))
171 local tmp
= minetest
.get_item_group(itemstring
, "bouncy")
174 desc
= desc
.. minetest
.colorize(tt
.COLOR_DEFAULT
, S("Bouncy (@1%)", tmp
))
178 tmp
= def
.light_source
179 if tmp
and tmp
>= 1 then
181 desc
= desc
.. minetest
.colorize(tt
.COLOR_DEFAULT
, S("Luminance: @1", tmp
))