Add API and README docs

This commit is contained in:
Wuzzy 2016-12-07 19:22:15 +01:00
parent 61f17c9af1
commit 21ce353beb
2 changed files with 42 additions and 0 deletions

30
API.md Normal file
View File

@ -0,0 +1,30 @@
# API documentation for [`sfinv_buttons`]
Use this API to add your own buttons to the page.
## `sfinv_buttons.register_button(name, def)
* `name`: Unique button identifier
* `def`: Coniguration table (see below)
### Fields of `def`
* `title`: Human-readable text on the button
* `action(player)`: Function is called when button is triggered
* `player`: ObjectRef to player who triggered the button
* Default: Nothing happens
* `tooltip: A tooltip for the button (optional, only use it for an additional, non-critical explanation)
* `image`: Texture name for the image to show left of the button (optional)
* `show(player)`: Shall return `true` if the button should be displayed (optional)
* `player`: ObjectRef to player who triggered the button
* Default: Always shows button
## Limits
* Up to 18 buttons can be registered
## Recommendations
* Try to summarize the most important information on the button
* Test if the button title still fits when having >= 9 and <= 18 buttons at a resolution of 800×600
* 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
* If you like to add many buttons, consider adding your own `sfinv` page instead

12
README.md Normal file
View File

@ -0,0 +1,12 @@
# Simple Fast Inventory Buttons [`sfinv_buttons`]
This mod adds a new tab (“More”) to the Simple Fast Inventory [`sfinv`] on
which other mods can add their buttons to make it easier to access their
core functionality.
The idea is to free users from typing in lame-ass chat commands. ;-)
## API
The API is documented in `API.md`.
## Mod license
MIT License