1 local S
= minetest
.get_translator("tt")
4 tt
.COLOR_DEFAULT
= "#d0ffd0"
5 tt
.COLOR_DANGER
= "#ffff00"
6 tt
.COLOR_GOOD
= "#00ff00"
9 tt
.registered_snippets
= {}
11 tt
.register_snippet
= function(func
)
12 table.insert(tt
.registered_snippets
, func
)
15 -- Register core snippets
17 dofile(minetest
.get_modpath(minetest
.get_current_modname()).."/snippets.lua")
19 -- Apply item description updates
21 local function append_snippets()
22 for itemstring
, def
in pairs(minetest
.registered_items
) do
23 if itemstring
~= "" and itemstring
~= "air" and itemstring
~= "ignore" and itemstring
~= "unknown" and def
~= nil and def
.description
~= nil and def
.description
~= "" and def
._tt_ignore
~= true then
24 local desc
= def
.description
25 local orig_desc
= desc
28 for s
=1, #tt
.registered_snippets
do
29 local str
, snippet_color
= tt
.registered_snippets
[s
](itemstring
)
30 if snippet_color
== nil then
31 snippet_color
= tt
.COLOR_DEFAULT
32 elseif snippet_color
== false then
42 desc
= desc
.. minetest
.colorize(snippet_color
, str
)
48 if desc
~= def
.description
then
49 minetest
.override_item(itemstring
, { description
= desc
, _tt_original_description
= orig_desc
})
55 minetest
.register_on_mods_loaded(append_snippets
)