Inputs2.lua

Download Latest Version

Inputs2 is a small library which makes it easier to disable and override the player's input. It is not fully backwards compatible with Inputs, but it doesn't take much effort to update old code.

Installation
Save the above file as inputs2.lua and drop it in the LuaScriptsLib folder.

How to use
To use this api, add this to your lunadll.lua or lunaworld.lua:

When the API is loaded, it will monitor all of the key press states of each Player object and store them in the inputs2.state table. Instead of a basic boolean, the state will be stored as one of four constants:

inputs2.UP (untouched) inputs2.PRESS (was just pressed) inputs2.HOLD (currently held down) inputs2.RELEASE (just released)

You can get the state for a given key by using the corresponding player index and key name in lowercase, like so:

player.jumpKeyPressing --> inputs2.state[1].jump

player2.dropItemKeyPressing --> inputs2.state[2].dropitem

inputs2[#].any gets the first of those states in that order from all of the Player object's inputs.

If inputs2.locked[#].keyname is set to true, the corresponding movement will be disabled without impacting inputs2.state[#].keyname. If inputs2.frozen[#].keyname is true, the respective inputs2.state[][] entry will stop updating and the associated Player object will react accordingly every frame the input stays frozen. A key can be locked and frozen simultaneously to disable movement and freeze the state, and the all key name can be used to lock and/or freeze all inputs for a given Player object.

If inputs2.debug is set to true, the states of each key will be displayed on the side of the screen.

Example code
This will replace spin jumping with a boomerang, but only for player 1. Player 2 will function normally.

when called, freezeRun will prevent the specified player from changing their horizontal movement for 60 frames.