isaacscript-common
Version:
Helper functions and features for IsaacScript mods.
90 lines • 5.32 kB
TypeScript
import { ButtonAction, Controller, ControllerIndex, Keyboard } from "isaac-typescript-definitions";
export declare const MODIFIER_KEYS: readonly [Keyboard.LEFT_SHIFT, Keyboard.LEFT_CONTROL, Keyboard.LEFT_ALT, Keyboard.LEFT_SUPER, Keyboard.RIGHT_SHIFT, Keyboard.RIGHT_CONTROL, Keyboard.RIGHT_ALT, Keyboard.RIGHT_SUPER];
export declare const MOVEMENT_BUTTON_ACTIONS: readonly [ButtonAction.LEFT, ButtonAction.RIGHT, ButtonAction.UP, ButtonAction.DOWN];
export declare const MOVEMENT_BUTTON_ACTIONS_SET: ReadonlySet<ButtonAction>;
export declare const SHOOTING_BUTTON_ACTIONS: readonly [ButtonAction.SHOOT_LEFT, ButtonAction.SHOOT_RIGHT, ButtonAction.SHOOT_UP, ButtonAction.SHOOT_DOWN];
export declare const SHOOTING_BUTTON_ACTIONS_SET: ReadonlySet<ButtonAction>;
/**
* Helper function to get the enum name for the specified `Controller` value. Note that this will
* trim off the "BUTTON_" prefix.
*
* Returns undefined if the submitted controller value was not valid.
*/
export declare function controllerToString(controller: Controller): string | undefined;
/**
* Helper function to get the movement actions that the specified `ControllerIndex` is currently
* pressing down. This returns an array because a player can be holding down more than one movement
* key at a time.
*/
export declare function getMoveButtonActions(controllerIndex: ControllerIndex): readonly ButtonAction[];
/**
* Helper function to get the shooting actions that the specified `ControllerIndex` is currently
* pressing down. This returns an array because a player can be holding down more than one shooting
* key at a time.
*/
export declare function getShootButtonActions(controllerIndex: ControllerIndex): readonly ButtonAction[];
/**
* Helper function to check if a player is pressing a specific button (i.e. holding it down).
*
* This is a variadic version of `Input.IsActionPressed`, meaning that you can pass as many buttons
* as you want to check for. This function will return true if any of the buttons are pressed.
*/
export declare function isActionPressed(controllerIndex: ControllerIndex, ...buttonActions: readonly ButtonAction[]): boolean;
/**
* Helper function to iterate over all inputs to determine if a specific button is pressed (i.e.
* being held down).
*
* This function is variadic, meaning you can pass as many buttons as you want to check for. This
* function will return true if any of the buttons are pressed.
*/
export declare function isActionPressedOnAnyInput(...buttonActions: readonly ButtonAction[]): boolean;
/**
* Helper function to check if a player is triggering a specific button (i.e. pressing and releasing
* it).
*
* This is a variadic version of `Input.IsActionTriggered`, meaning that you can pass as many
* buttons as you want to check for. This function will return true if any of the buttons are
* triggered.
*/
export declare function isActionTriggered(controllerIndex: ControllerIndex, ...buttonActions: readonly ButtonAction[]): boolean;
/**
* Iterates over all inputs to determine if a specific button is triggered (i.e. held down and then
* released).
*
* This function is variadic, meaning you can pass as many buttons as you want to check for. This
* function will return true if any of the buttons are pressed.
*/
export declare function isActionTriggeredOnAnyInput(...buttonActions: readonly ButtonAction[]): boolean;
/**
* Helper function to see if a specific keyboard key is being held down by the player.
*
* This function is variadic, meaning you can pass as many keyboard values as you want to check for.
* This function will return true if any of the values are pressed.
*/
export declare function isKeyboardPressed(...keys: readonly Keyboard[]): boolean;
/**
* Helper function to check if one or more modifier keys are being pressed down on the keyboard.
*
* A modifier key is defined as shift, control, alt, or Windows.
*/
export declare function isModifierKeyPressed(): boolean;
export declare function isMoveAction(buttonAction: ButtonAction): boolean;
export declare function isMoveActionPressed(controllerIndex: ControllerIndex): boolean;
export declare function isMoveActionPressedOnAnyInput(): boolean;
export declare function isMoveActionTriggered(controllerIndex: ControllerIndex): boolean;
export declare function isMoveActionTriggeredOnAnyInput(): boolean;
export declare function isShootAction(buttonAction: ButtonAction): boolean;
export declare function isShootActionPressed(controllerIndex: ControllerIndex): boolean;
export declare function isShootActionPressedOnAnyInput(): boolean;
export declare function isShootActionTriggered(controllerIndex: ControllerIndex): boolean;
export declare function isShootActionTriggeredOnAnyInput(): boolean;
/**
* Helper function to get the string that would be typed if someone pressed the corresponding key.
* This is useful for creating in-game chat.
*
* Note that this function will only work for the keyboard values that are printable. Thus, it will
* return undefined for e.g. `Keyboard.LEFT_SHIFT` (340). If all you want is the corresponding name
* of the key, then simply use the enum reverse mapping (e.g. `Keyboard[keyboard]`).
*/
export declare function keyboardToString(keyboard: Keyboard, uppercase: boolean): string | undefined;
//# sourceMappingURL=input.d.ts.map