Page 1 of 1

Restricting characters for levels

Posted: Wed May 18, 2022 1:54 pm
by Wrath666
Is there a way to restrict the playable character to 1 specific character for a level without using Character Blocks? Like maybe a lua code or something?

Re: Restricting characters for levels

Posted: Wed May 18, 2022 5:24 pm
by deice
while this should probably go inside the "lunalua help" subforum, you can filter the player's character as such:

Code: Select all

local setChar = CHARACTER_MARIO

function onStart()
	player.character = setChar 
end
the list of character constants can be found here, you can replace "CHARACTER_MARIO" with any of them.
i believe that enjl said this feature won't require lua in the next version.

Re: Restricting characters for levels

Posted: Sat May 21, 2022 11:10 am
by Hoeloe
deice wrote:
Wed May 18, 2022 5:24 pm
while this should probably go inside the "lunalua help" subforum, you can filter the player's character as such:

Code: Select all

local setChar = CHARACTER_MARIO

function onStart()
	player.character = setChar 
end
the list of character constants can be found here, you can replace "CHARACTER_MARIO" with any of them.
i believe that enjl said this feature won't require lua in the next version.
It's actually better to use player:transform(setChar) instead of setting the character field directly. Changing the character in this way is the same as hitting a character switch block, which is not true of just assinging to player.character.