OpenMiner/docs/lua-api-recipe.md

129 lines
1.6 KiB
Markdown
Raw Normal View History

# Lua API: Recipe
## Example
### Crafting recipe
```lua
mod:crafting_recipe {
result = {
id = "default:wooden_axe",
amount = 1
},
pattern = {
"##",
"#|",
" |"
},
keys = {
['#'] = "default:oak_planks",
['|'] = "default:stick",
}
}
```
### Smelting recipe
```lua
mod:smelting_recipe {
input = {
id = "default:iron_ore",
amount = 1
},
output = {
id = "default:iron_ingot",
amount = 1
}
}
```
## Attributes
### Crafting recipe
#### `result`
Item stack created with the craft.
Example
```lua
result = {
id = "default:wooden_axe",
amount = 1
}
```
Possible attributes:
- `id`: String ID of the item created.
2020-03-29 15:36:59 +02:00
- `amount`: Amount of items in the created stack.
#### `pattern`
Pattern of the craft.
Example:
```lua
pattern = {
"##",
"#|",
" |",
}
```
#### `keys`
Mapping of the characters used in `pattern` to actual item string IDs.
2020-05-20 20:53:22 +02:00
**Note:** Keys can also be groups. See [Item#Attributes#groups](lua-api-item.md#groups) for more details.
2020-03-29 15:36:59 +02:00
Example:
```lua
keys = {
['#'] = "default:oak_planks",
['|'] = "default:stick",
}
```
### Smelting recipe
#### `input`
Item stack used as input for the recipe.
Example:
```lua
input = {
id = "default:cobblestone",
amount = 1
}
```
Possible attributes:
- `id`: String ID of the item created.
2020-03-29 15:36:59 +02:00
- `amount`: Amount of items in the created stack.
2020-05-20 20:53:22 +02:00
**Note:** `id` can also be a group. See [Item#Attributes#groups](lua-api-item.md#groups) for more details.
#### `output`
Item stack created with the recipe.
Example:
```lua
output = {
id = "default:stone",
amount = 1
}
```
Possible attributes:
- `id`: String ID of the item created.
- `amount`: Amount of items in the created stack