Character Switcher by Enjl

Share and discuss custom LunaLua code and content packs for SMBX2.
Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9737
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Character Switcher by Enjl

Postby Emral » Thu Dec 31, 2020 4:40 am

https://drive.google.com/file/d/1en2jvo ... sp=sharing

Image

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.

PROX
Banned
Posts: 1953
Joined: Sun Jul 06, 2014 8:50 pm

Re: Character Switcher by Enjl

Postby PROX » Thu Dec 31, 2020 6:33 am

this could be a cool way to make a hybrid level for characters.

8lue Storm
Volcano Lotus
Volcano Lotus
Posts: 593
Joined: Thu Jan 18, 2018 9:53 am
Flair: its pronounced bluestorm

Re: Character Switcher by Enjl

Postby 8lue Storm » Thu Dec 31, 2020 6:49 pm

nice going

time to make peach & toad's wacky hellscape adventure 2


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 0 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari