diff --git a/docs/index.md b/docs/index.md index df704eba..655c692a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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) diff --git a/docs/lua-api-key.md b/docs/lua-api-key.md new file mode 100644 index 00000000..9da0dc9e --- /dev/null +++ b/docs/lua-api-key.md @@ -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. + diff --git a/docs/lua-api-mod.md b/docs/lua-api-mod.md index 09b53faf..d77b4c2e 100644 --- a/docs/lua-api-mod.md +++ b/docs/lua-api-mod.md @@ -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. diff --git a/mkdocs.yml b/mkdocs.yml index b4157d9f..f11b980c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -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'