create documentation

This commit is contained in:
Dirk Sohler 2018-09-22 17:28:08 +02:00
parent 252ad038db
commit 85c7455a19
No known key found for this signature in database
GPG Key ID: B9751241BD7D4E1A
6 changed files with 48 additions and 2 deletions

@ -1 +1,42 @@
WIP
*“Universal Hammers” adds various hammers that can be used to crush nodes.*
## Default usage
The mod registers various hammers. Those hammers can be crafted from sticks and their respective material. Different material hammers can be used different times before they break.
![hammers and the needed materials](screenshots/hammers.png)
Crafting the hammers needs two sticks and two of the material as shown in the image above. Crafting is then done very similar to the other tools.
![example hammer crafting](screenshots/crafting.png)
The recipe shape is always the same, just interchange the head material. If the moreores mod is installed and loaded hammers can be crafted from the mods ores in the same way as shown above.
## Default functionality
The hammers added by this mod can be used to crush material into “softer” material.
![stone crushing process](screenshots/process.png)
The three default sandstone types can be crushed into the corresponding three default sand types, too.
## API usage
The *Universal Hammer API* can be used by calling the `uniham.register_hammer` function. This function takes two parameters, the ID and the definition table.
```lua
uniham.register_hammer('my_cool_id', {
name = 'My Cool Hammer',
head = 'mymod_my_cool_texture.png',
craft = 'mymod:my_cool_item',
uses = 200
})
```
This registers a hammer with the name “My Cool Hammer” that has the ID `mymod:my_cool_id`. The head base texture is `mymod_my_cool_texture.png` and the texture is automatically masked to form a hammer head.
The hammer is crafted like the provided hammers with two sticks and two of the items provided for `craft`.
`uses` defines how often the hammer can be used. The value also gets stored in the tools definition as `_uniham.uses` that can be used by a custom `on_use` function for example
The registration table allows another, absolutely optional, parameter `on_use`. This parameter has to be a function being, well, an `on_use` function [as defined by the Minetest API](https://dev.minetest.net/register_node#on_use). This overrides the built-in `on_use` function that replaces the nodes as described. Custom `on_use` function have to handle wear and itemstack returning.

@ -24,4 +24,9 @@ dofile(uniham.syspath..DIR_DELIM..'registry.lua')
-- Clean up
uniham = nil
--
-- `uniham.register_hammer` is kept available for API purposes
uniham.replacements = nil
uniham.syspath = nil
uniham.modpath = nil
uniham.use_hammer = nil

BIN
screenshots/crafting.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

BIN
screenshots/hammers.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
screenshots/process.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 927 B

After

Width:  |  Height:  |  Size: 127 B