Inputs2.lua
Inputs2 is a small library which makes it easier to override the player's input. It is not fully backwards compatable with Inputs, but it doesn't take much effort to update old code.
Installation
Drop the inputs2.lua file in the LuaScriptsLib folder.
How to use
When the API is loaded, it will monitor the key press states of all the player inputs and store them in the inputs2.state[] table. You can access the state for a given key by using the corresponding key name in lowercase (i.e. player.jumpKeyPressing --> inputs2.state[1]["jump"], player2.dropItemKeyPressing --> inputs2.state[2]["dropitem"]) as well as "any" for any key. Instead of a basic boolean, Inputs2 stores the state as one of four constants: inputs.UP, inputs.PRESS, inputs.HOLD, and inputs.RELEASE.
If inputs2.locked[playerindex][keyname] is set to true, the corresponding movement will be disabled without impacting inputs.state[]. inputs2.locked["all"] locks all inputs.
If inputs2.debug is set to true, the states of each key will be displayed on the side of the screen.
Example
local inputs2 = loadAPI("inputs2");
inputs2.locked[1]["altjump"] = true
function onLoop ()
if inputs2.state[1]["altjump"] == inputs.PRESS then
playSFX(26)
-- Get direction multiplier
local dirMult = -1
if player:mem (0x106, FIELD_WORD) ~= -1 then
dirMult = 1
end
-- Spawn boomerang
local boomerang = NPC.spawn (292, player.x + (32*dirMult), player.y, 1)
boomerang.speedX = 12*dirMult + player.speedX
boomerang:mem (0x110, FIELD_DFLOAT, 1)
end
end
This will replace spin jumping with a boomerang, but only for player 1. Player 2 will function normally.