Version 1.0.0
[minetest_tt.git] / API.md
bloba510553ce12ff3b5dcb160fb4a5ab30266395e4f
1 # Tooltip API
2 This API explains how to handle the extended item tooltips (`description` field).
4 ## Fields
6 Add these to the item definition.
8 * `_tt_ignore`: If `true`, the `description` of this item won't be altered at all
9 * `_tt_help`: Custom help text
11 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.
13 ## `tt.register_snippet(func)`
15 Register a custom snippet function.
16 `func` is a function of the form `func(itemstring)`.
17 It will be called for (nearly) every itemstring.
19 Returns: Two values, the first one is required.
20 1st return value: A string you want to append to this item or `nil` if nothing shall be appended.
21 2nd return value: If nil, `tt` will take of the text color. If a ColorString in `"#RRGGBB"` format, entire text is colorized in this color. Return `false` to force `tt` to not apply text any colorization (useful if you want to call `minetest.colorize` yourself.
23 Example:
25 ```
26 tt.register_snippet(function(itemstring)
27         if minetest.get_item_group(itemstring, "magic") == 1 then
28                 return "This item is magic"
29         end
30 end)
31 ```