Lua API: Key

Example

mod:key {
    id = "inventory",
    name = "Inventory",
    default_key = "E",

    callback = function(keyID, client)
        show_inventory(keyID, client)
    end
}

Attributes

callback

Function called when the key is pressed.

Example:

callback = function(keyID, client)
    show_inventory(keyID, client)
end

default_key

Keyboard key mapped to this key by default.

Example:

default_key = "E"

Names are defined here.

name

Name of the key. Optional field, uses id if not defined.

Example:

name = "Inventory"

id

ID of the key. Mandatory field.

Example:

id = "inventory"

IDs are usually of the form mod:key but the mod: prefix is prepended automatically so it's not needed.