Inputs.lua
Inputs is a small library which makes it easier to override the player's input.
Installation
Drop the inputs.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 inputs.state[] table. You can access the state for a given key by using the corresponding key name in lowercase (i.e. player.jumpKeyPressing --> inputs.state["jump"], player.dropItemKeyPressing --> inputs.state["dropitem"]). Instead of a basic boolean, Inputs stores the state as one of four constants: inputs.UP, inputs.PRESS, inputs.HOLD, and inputs.RELEASE.
If inputs.locked[keyname] is set to true, the corresponding movement will be disabled without impacting inputs.state[].
If inputs.debug is set to true, the states of each key will be displayed on the side of the screen.
Example
local inputs = loadAPI("inputs");
inputs.locked["altjump"] = true
function onLoop ()
if inputs.state["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.