player.get_button_press_duration

a.k.a. player.get_button_time

This function was added to the Halo: The Master Chief Collection build of Halo: Reach in mid-July 2023, being backported from Halo 4's Megalo engine. Gametypes that use this function will likely fail to load on Xbox 360 builds of Halo: Reach (even when played via Xbox One backward compatibility).

This function checks whether a specified gameplay-related button is being held down on the gamepad; if so, it returns the number of script ticks for which the button has been held down. This function does not react to the keyboard, only works on host, and per statements by 343i developers is intended for debugging purposes only.

When multiple functions are mapped to the same button, they do not block each other; this function will return the same time in script ticks for both of them. Although buttons are identified by their mapped function (i.e. "the Jump button" instead of "A"), this function will return the correct duration even if the player is unable to trigger the mapped function. Players that are on the respawn screen, or out of grenades, for example, can still be detected as pressing the "throw grenades" button.

Per a 343i employee, this function is not "deterministic." It doesn't synch across the network or in Theater. If a gametype ever actually reacts to this function in any way that affects game or map state, then a Theater film of that play session will immediately desynch at that point in the match, rendering playback past that point impossible (Theater will show an error message and then forcibly return you to the lobby). To paraphrase the employee: "You should only use it for debugging, as a last resort."

This function returns number. Calling this function without storing its return value in a variable is an error.

Arguments

button

The name of a gameplay function to which a button can be mapped. In the following list, title-cased names (e.g. "Gameplay Function Name") refer to options in the MCC's gamepad control scheme editor.

jump
The button that's currently mapped to Jump.
switch_grenade
The button that's mapped to cycling through your grenades. This matches MCC's "Switch Grenades" function, but not "Select Next Grenade" or "Select Previous Grenade."
context_primary
The button that's currently mapped to Action.
melee_attack
The button that's currently mapped to meleeing.
equipment
The button that's currently mapped to Use Armor Ability.
throw_grenade
The button that's currently mapped to throwing a grenade.
fire_primary
The button that's currently mapped to Fire.
crouch
The button that's currently mapped to crouching.
scope_zoom
The button that's currently mapped to toggling your scope/zoom.
night_vision
The button that's currently mapped to Toggle Night Vision.
fire_secondary
The button that's currently mapped to Vehicle Function 1.
fire_tertiary
Unknown. This appears to always react to the B button; it doesn't correspond to any of the controls that MCC allows players to rebind in custom control schemes, and it doesn't differ between any of the built-in control schemes.
vehicle_trick
Either of the buttons mapped to Vehicle Function 2 and Vehicle Function 3.

Example

for each player do
   global.number[0] = current_player.get_button_press_duration(jump)
end

Notes