
This library allows you to have an arbitrary number of player states stored in your level (only using 1 actual player object). It's a less jank alternative to the supermario2 cheat.
The example from the gif is included in the download as a way to get started.
Docs:
Code: Select all
local cs = require("charswitcher")
cs.canSwitch = true -- disables switching if false
cs.mergePositions() -- instantly moves all clones to the current active player's position and section
cs.switchCharacter(number direction = 1, bool silent = false) -- Cycles through the character list in the given direction
cs.addCharacter(number id, table props) -- adds a character that's currently not in play. props can include x,y,powerup,direction,section,sfx, a function "render" (defaults to player:render) and a function onInit that is called when the player switches to that character.
cs.addCurrentCharacter(function onInit, function render, number or string sfx) -- invokes addCharacter with the properties used by player 1 at this moment.
cs.getChar(number idx) -- returns the character object at the index in the table
cs.registerSwitchFunction(function func, number direction) -- registers a function to be called for listening to inputs. When the function returns true, switchCharacter is invoked with the given direction to cycle through.