Table of Contents

Input library

ACSUtils provides a set of wrappers for GetPlayerInput to make writing correct input code easier.

Basic concepts

ACSUtils provide a way to easily check these all these states for every key without writing compliated GetPlayerInput expressions.

What's the point of "pressed" and "released"?

Say, you have an on-screen button to sell items that can be clicked with mouse:

if (/* check that mouse cursor is inside the button */)
    if (GetPlayerInput(-1, INPUT_BUTTONS) & BT_ATTACK)) // check left mouse button click
        SellItem();

This code is wrong. If the player clicks the button once, it will likely cause him to sell multiple items. That's because this code checks if the mouse button is down. But the mouse button may be down for multiple tics after a click, as it may not be immediately released.

To avoid this bug, you need to check if the button was up the previous tic, but is now down. And that's exactly what the pressed state means. The KeyPressed function contains all the repetitive code to perform this check:

if (/* check that mouse cursor is inside the button */)
    if (KeyPressed(BT_ATTACK)) // check left mouse button click
        SellItem();

Now the button works correctly. Performing an action on releasing the button can be done the same way using KeyReleased.

Functions

To check one key or a key combination:

Examples:

Checking one key:

if (KeyPressed(BT_ATTACK))
    print(s:"You clicked left mouse button");

Checking a key