Inputs.lua

From Moondust Wiki
Revision as of 13:53, 4 November 2015 by Rockythechao (talk | contribs) (Created page with "Category:LunaLua helper libraries [https://dl.dropboxusercontent.com/u/12431097/inputs.lua Download Latest Version] Inputs is a small library which makes it easier to ove...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Download Latest Version

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

if  inputs.state["altjump"] == inputs.PRESS  then
    player.powerup = PLAYER_HAMMER
end

This will replace spin jumping with giving the player a hammer suit.