[docs/lua-api-key.md] Added.

This commit is contained in:
Quentin Bazin 2020-06-19 03:39:58 +02:00
parent b45ac1cdbd
commit 5d741b30ee
4 changed files with 53 additions and 0 deletions

View File

@ -8,6 +8,7 @@
- [Dimension](lua-api-dimension.md)
- [Entity](lua-api-entity.md)
- [Item](lua-api-item.md)
- [Key](lua-api-key.md)
- [Recipe](lua-api-recipe.md)
- [Sky](lua-api-sky.md)
- [Tree](lua-api-tree.md)

47
docs/lua-api-key.md Normal file
View File

@ -0,0 +1,47 @@
# Lua API: Key
## Example
```lua
mod:key {
id = "inventory",
name = "Inventory",
default_key = "E"
}
mod:key_callback("default:inventory", function(client, screen_width, screen_height, gui_scale)
show_inventory(client, screen_width, screen_height, gui_scale)
end)
```
## Attributes
### `default_key`
Keyboard key mapped to this key by default.
Example:
```lua
default_key = "E"
```
### `name`
Name of the key. Optional field, uses `id` if not defined.
Example:
```lua
name = "Inventory"
```
### `id`
ID of the key. **Mandatory field.**
Example:
```lua
id = "inventory"
```
IDs are usually of the form `mod:key` but the `mod:` prefix is prepended automatically so it's not needed.

View File

@ -128,6 +128,10 @@ Defines an entity from a table, see [this page](lua-api-entity.md) for more info
Defines an item from a table, see [this page](lua-api-item.md) for more information.
### `key`
Defines a key from a table, see [this page](lua-api-key.md) for more information.
### `recipe`
Defines a recipe from a table, see [this page](lua-api-recipe.md) for more information.

View File

@ -12,6 +12,7 @@ nav:
- 'Dimension': 'lua-api-dimension.md'
- 'Entity': 'lua-api-entity.md'
- 'Item': 'lua-api-item.md'
- 'Key': 'lua-api-key.md'
- 'Recipe': 'lua-api-recipe.md'
- 'Sky': 'lua-api-sky.md'
- 'Tree': 'lua-api-tree.md'