DOCS added

master
Marco 2020-04-23 13:24:32 +02:00
parent e4ce34b3f6
commit 8522966fb9
1 changed files with 57 additions and 0 deletions

57
DOCS.md Normal file
View File

@ -0,0 +1,57 @@
# Scoreboard_lib docs
## 1. Scoreboard structure
A scoreboard is a custom object made of 2 HUD elements, the title and the background, plus a group of two sub-elements: the text and the images. Picture the background as the container of all the things you want to showcase in your HUD. Those things go in the sub-elements.
### 1.1. Declaration
To declare a new scoreboard, simply do
`local scoreboard = Scoreboard:new({parameters})`
The parameters it takes are the following:
* `player`: the player to assign the scoreboard to
* `position`: the scoreboard position (as in any other HUD)
* `alignment`: same
* `bg`: the picture to put in the background
* `bg_scale`: its scaling
* `title`: the default text
* `title_alignment`
* `title_offset`
* `title_color`
* `sub_img_elems`: (table) whatever image to add to the scoreboard
* `sub_txt_elems`: (table) whatever text to add to the scoreboard
### 1.2. Sub-elements
Sub-elements are HUDs added on top of the main container, sharing the same position. This means two things:
1. As a HUD, they take the same parameters a HUD takes. They are clones respectively of the background and the title, so if you skip some parameter, they'll keep their reference default value.
2. If you wanna move them around, you must tweak the offset, **NOT** the position. If you change the position, they may look fine in a screen resolution, but not in another. In order to prevent it, `scoreboard_lib` automatically overrides the position with the scoreboard's.
Have a look at [the example file](https://gitlab.com/zughy-friends-minetest/scoreboard_lib/-/blob/master/scoreboard.example) to see a complete scoreboard declaration.
## 2. Configuration
Install it as any other mod `¯\_(ツ)_/¯`
## 2.1. Functions
* `new({params})`: creates a new scoreboard
* `show()`: makes the scoreboard appear
* `hide()`: makes the scoreboard disappear (but it's still assigned to the player)
* `remove()`: deletes it
* `update(scoreboard_params, txt_elems, img_elems)`: updates only the mentioned parameters. For instance, calling
```
update(nil, nil, {my_custom_img = {
text = "pic2.png"
})
```
updates just the text of the sub-element `my_custom_img`.
There is also a getter, to obtain the scoreboard associated with a player
* scoreboard_lib.
## 3. Collaborating
Something's wrong? Feel free to open an issue, go for a merge request and whatnot. I'd really appreciate it :)
## 4. About the author(s)
I'm Zughy (Marco), a professional Italian pixel artist who fights for FOSS and digital ethics. If this library spared you a lot of time and you want to support me somehow, please consider donating on [LiberaPay](https://it.liberapay.com/EticaDigitale/) directly to my educational Italian project (because not everyone speaks English and Italian media don't talk about these topics much). Also, this project wouldn't have been possible if it hadn't been for some friends who helped me testing through: `SonoMichele`, `_Zaizen_` and `Xx_Crazyminer_xX`