Add some support for >18 buttons
[minetest_sfinv_buttons.git] / API.md
blob37036a900e41b94f3ed3c7943fd73495fea15875
1 # API documentation for [`sfinv_buttons`]
3 Use this API to add your own buttons to the page.
5 ## `sfinv_buttons.register_button(name, def)
7 * `name`: Unique button identifier
8 * `def`: Coniguration table (see below)
10 ### Fields of `def`
11 * `title`: Human-readable text on the button
12 * `action(player)`: Function is called when button is triggered
13     * `player`: ObjectRef to player who triggered the button
14     * Default: Nothing happens
15 * `tooltip: A tooltip for the button (optional, only use it for an additional, non-critical explanation)        
16 * `image`: Texture name for the image to show left of the button (optional)
17 * `show(player)`: Shall return `true` if the button should be displayed (optional)
18     * `player`: ObjectRef to player who triggered the button
19     * Default: Always shows button
21 ## Limits
23 * Up to 18 buttons can be registered
25 ## Recommendations
27 * Try to summarize the most important information on the button
28 * Test if the button title still fits when having >= 9 and <= 18 buttons at a resolution of 800×600
29 * It is recommended to only add buttons to access core mod functionality and not for every minor feature. The rule of thumb is to add at most 1 button per mod
30 * If you like to add many buttons, consider adding your own `sfinv` page instead