Buttons New
A button is one input flag of PlayerAuthInputPacket (Input Data in the game schema). The game build 1.26.6201.0
names 66 of them, indexed 0 to 65; xiao.cmd.buttons maps each Lua name to its index.
A button is an index, not a bit mask: 66 flags do not fit in a Lua number (exact up to 2^53) and LuaJIT bit
works on 32 bits. Every method takes a name ("jump_down") or an index (3, xiao.cmd.buttons.jump_down).
At a glance
In authinput every index from 0 to 127 works (indices past 65 have no name in this build). In createmove only
the buttons the client simulates exist:
Functions
cmd:get_buttons(): number[]
Returns: the indices of the buttons that are down, ascending. In authinput every flag of the packet
({48, 50} for a player standing still); in createmove only the buttons of the table above.
cmd:set_buttons(list)
Replaces every button: the listed buttons are down, all others are up. In createmove it sets jump_down,
sprint_down and sneak_down from the list.
Returns: nothing.
Errors:
cmd:has_button(button): boolean
Returns: true when the button is down.
Errors:
cmd:set_button(button, down)
Returns: nothing.
Errors: as has_button; in createmove, up, down, left and right raise
button 'up' follows the move vector in createmove (use set_move).
cmd:remove_button(button)
Same as set_button(button, false).
Returns: nothing.
Errors: as set_button.
Direction buttons
up, down, left and right say which way the move vector points. In authinput, set_move and
rotate_movement set them again from the new vector (up when forward is positive, left when left is positive); a
set_button after that wins. The diagonal buttons (up_left, up_right, down_left, down_right) belong to the
touch d-pad: a keyboard sends up + right for W+D, never up_right, so they are never changed for you.
Data buttons
perform_item_interaction, perform_block_actions, perform_item_stack_request and is_in_client_predicted_vehicle
announce data that the packet carries. Setting them by hand without that data makes the server reject or misread the
input.
Table of buttons
Exact names read in the game schema of build 1.26.6201.0 (enum PlayerAuthInputData). The Lua name is the schema name
in lower case with _ between words. The "client source" column is where the client takes the flag from when it
builds the packet (MoveInputComponent flag bit, state bit at +96, or event of the tick).
"Raw bit" is the second state word of MoveInputComponent (+16). The flag, state, raw and byte sources are read in
the game function that copies MoveInputComponent into the packet; "tick event", "game setting" and "simulation" only
describe where the other flags come from. The packet log decoder (input_flag of msg:fields(), Copy as Lua, Copy as
receiver) reads its names from the same table, so a flag has the same name in xiao.cmd and in the packet log. The
short names the decoder used before are still accepted by the encoder, see
Renamed fields.
Complete example
Hold sneak on the server only while the player stands still, and print every tick event the client sends.
local events = {}
for name, index in pairs(xiao.cmd.buttons) do
if name:find("^start_") or name:find("^stop_") then events[index] = name end
end
xiao.cmd.hook("authinput", "buttons_demo", function(cmd)
local forward, left = cmd:get_move()
if forward == 0 and left == 0 then
cmd:set_button("sneak_down")
cmd:set_button("sneaking")
end
for _, index in ipairs(cmd:get_buttons()) do
if events[index] then print(cmd:command_number(), events[index]) end
end
end)