Add 'API'

Mikita Wiśniewski 2023-04-16 01:15:53 +00:00
parent d55681d43f
commit fa189d82a8
1 changed files with 146 additions and 0 deletions

146
API.md Normal file

@ -0,0 +1,146 @@
This mod adds and utilizes many functions (which form mod's API), and some of them can be used to expand its content.
Useful links if you're getting started with MT modding:
* [Minetest Modding Book](https://rubenwardy.com/minetest_modding_book/en/index.html) (unofficial but still must-have for beginners)
* [Minetest Lua API](https://minetest.gitlab.io/minetest/) (useful when you're trying to find a specific function in Minetest itself)
* [Documentation for Lua](https://www.lua.org/docs.html) (programming language that Minetest uses for mods)
Plus some MCL-specific stuff:
* [MineClone's API](https://git.minetest.land/MineClone2/MineClone2/src/branch/master/API.md) (good as a starting point; references many API functions that you may want to use)
# Chairs and tables
## `function mcl_decor.register_chair_and_table(name, desc, desc2, material, tiles, group)`
This function registers both chair and a table at once using params provided. Quite useful if your mod adds new type(s) of wood and you want to support mine.
**Parameters:**
* `name`: name of the wood type, which will be included in the node name as mcl_decor:**name**_chair
Example: `"larch"`
* `desc`: description (visible name) for the chair. *Hint: Append S before it and put it into parentheses to make it translatable*
Example: `S("Larch Chair")`
* `desc2`: description (visible name) for the table. *Hint: Append S before it and put it into parentheses to make it translatable*
Example: `S("Larch Table")`
* `material`: name (including modname) of node which should be used as main material to craft registered chairs and tables
Example: `"mcl_larch:larchwood"`
* `tiles`: texture which will be used for registered chairs and tables
Example: `"mcl_larch_larchwood.png"`
* `group`: luatable of groups, which applies only if specified (if not, there's a fallback luatable which pretty much suits ANY wood out there). you can ignore that param unless your type of wood is slippery, bouncy or fire-resistant. [About MCL groups](https://git.minetest.land/MineClone2/MineClone2/src/branch/master/GROUPS.md)
**Full usage example:**
* `mcl_decor.register_chair_and_table("larch", S("Larch Chair"), S("Larch Table"), "mcl_larch:larchwood", "mcl_larch_larchwood.png")`
### [[See definiton]](../src/branch/master/wooden.lua#L6) [[See usage]](../src/branch/master/wooden.lua#L152)
## `function mcl_decor.register_slab_table(name, desc, material, tiles, group)`
This function registers a slab table.
**Parameters:**
* `name`: name of the wood type, which will be included in the node name as mcl_decor:**name**_stable
Example: `"larch"`
* `desc`: description (visible name) for the slab table. *Hint: Append S before it and put it into parentheses to make it translatable*
Example: `S("Larch Slab Table")`
* `material`: name (including modname) of node which should be used as main material to craft the slab table
Example: `"mcl_larch:larchwood"`
* `tiles`: texture which will be used for the slab table
Example: `"mcl_larch_larchwood.png"`
* `group`: luatable of groups, which applies only if specified (if not, there's a fallback luatable which pretty much suits ANY wood out there). you can ignore that param unless your type of wood is slippery, bouncy or fire-resistant. [About MCL groups](https://git.minetest.land/MineClone2/MineClone2/src/branch/master/GROUPS.md)
**Full usage example:**
* `mcl_decor.register_slab_table("larch", S("Larch Slab Table"), "mcl_larch:larchwood", "mcl_larch_larchwood.png")`
### [[See definiton]](../src/branch/master/wooden.lua#L109) [[See usage]](../src/branch/master/wooden.lua#L161)
# Hedges
## `function mcl_decor.register_hedge(name, desc, material, tiles)`
This function registers a hedge.
**Parameters:**
* `name`: name of the wood type, which will be included in the node name as mcl_fences:**name**_hedge
Example: `"larch"`
* `desc`: description (visible name) for the hedge. *Hint: Append S before it and put it into parentheses to make it translatable*
Example: `S("Larch Hedge")`
* `material`: name (including modname) of node which should be used as main material to craft the hedge
Example: `"mcl_larch:larchleaves"`
* `tiles`: texture which will be used for the hedge
Example: `"mcl_larch_larchleaves.png"`
**Full usage example:**
* `mcl_decor.register_hedge("larch", S("Larch Hedge"), "mcl_larch:larchleaves", "mcl_larch_larchleaves.png")`
### [[See definiton]](../src/branch/master/hedges.lua#L6) [[See usage]](../src/branch/master/hedges.lua#L30)
# Paths
## `function mcl_decor.register_path(name, desc, material, tiles, sgroup, sounds)`
This function registers a path. Quite useful if your mod adds new type(s) of stone and you want to support mine.
**Parameters:**
* `name`: name of the wood type, which will be included in the node name as mcl_decor:**name**_path
Example: `"slate"`
* `desc`: description (visible name) for the path. *Hint: Append S before it and put it into parentheses to make it translatable*
Example: `S("Slate Path")`
* `material`: name (including modname) of node which should be used as main material to craft the path
Example: `"mcl_slate:slate"`
* `tiles`: texture which will be used for the path
Example: `"mcl_slate_slate.png"`
* `sgroup`: group which will be applied to the path alongside predefined ones. based on the material: use `"pickaxey"` if it is pickaxey and `"shovely"` if it is shovely. [About MCL groups](https://git.minetest.land/MineClone2/MineClone2/src/branch/master/GROUPS.md)
Example: `"pickaxey"`
*
**Full usage example:**
* ```
mcl_decor.register_path(
"slate",
S("Slate Path"),
"mcl_slate:slate",
"mcl_slate_slate.png",
"pickaxey",
mcl_sounds.node_sound_stone_defaults()
)
```