Remove docs on limit cuz it no longer exists
[minetest_sfinv_buttons.git] / API.md
blobcdcba3a25b82fcd09c76323a131df1ba5694dd0c
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 ## Recommendations
23 * Try to summarize the most important information on the button
24 * Test if the button title still fits when having >= 9 and <= 18 buttons at a resolution of 800×600
25 * 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
26 * If you like to add many buttons, consider adding your own `sfinv` page instead