Is it possible to make an NPC appear only once.

Post here for help and support regarding LunaLua and SMBX2's libraries and features.
User avatar
CerealCat
Spiny
Spiny
Posts: 28
Joined: Thu Jul 11, 2019 5:31 pm
Flair: twitch.tv/mrcerealcat
Pronouns: he/him they/them
Contact:

Is it possible to make an NPC appear only once.

Postby CerealCat » Fri Oct 22, 2021 3:22 am

I want the player to find a Yoshi in one level, but have it only appear once. Even if they leave the level and come back, I don't want it to reappear. Even if they accidentally kill the Yoshi, I don't want it to reappear. Is that possible?
Just having a good time!
Image

User avatar
deice
Bit
Bit
Posts: 69
Joined: Fri Jul 23, 2021 7:35 am

Re: Is it possible to make an NPC appear only once.

Postby deice » Fri Oct 22, 2021 7:34 am

put the yoshi in it's own layer, and then put this code into the level's lua file.

Code: Select all

local LAYER_NAME = "test" --name of the yoshi's layer

function onStart()
	if(SaveData.seenYoshiL == true) then
		Layer.get(LAYER_NAME):hide(true)
	end
	
	SaveData.seenYoshiL = true
end
be sure to test this in the episode itself and not the level editor, as the play tester might not maintain SaveData between multiple tests

User avatar
CerealCat
Spiny
Spiny
Posts: 28
Joined: Thu Jul 11, 2019 5:31 pm
Flair: twitch.tv/mrcerealcat
Pronouns: he/him they/them
Contact:

Re: Is it possible to make an NPC appear only once.

Postby CerealCat » Fri Oct 22, 2021 5:46 pm

deice wrote:
Fri Oct 22, 2021 7:34 am
put the yoshi in it's own layer, and then put this code into the level's lua file.

Code: Select all

local LAYER_NAME = "test" --name of the yoshi's layer

function onStart()
	if(SaveData.seenYoshiL == true) then
		Layer.get(LAYER_NAME):hide(true)
	end
	
	SaveData.seenYoshiL = true
end
be sure to test this in the episode itself and not the level editor, as the play tester might not maintain SaveData between multiple tests
Thanks, works flawlessly!
Just having a good time!
Image

User avatar
MrDoubleA
Posts: 308
Joined: Mon Aug 20, 2018 7:02 am
Pronouns: he/him
Contact:

Re: Is it possible to make an NPC appear only once.

Postby MrDoubleA » Sun Nov 07, 2021 5:58 am

deice wrote:
Fri Oct 22, 2021 7:34 am
put the yoshi in it's own layer, and then put this code into the level's lua file.

Code: Select all

local LAYER_NAME = "test" --name of the yoshi's layer

function onStart()
	if(SaveData.seenYoshiL == true) then
		Layer.get(LAYER_NAME):hide(true)
	end
	
	SaveData.seenYoshiL = true
end
be sure to test this in the episode itself and not the level editor, as the play tester might not maintain SaveData between multiple tests
Side note: the tester DOES keep SaveData between tests. However, it will only maintain it between sessions if it was saved (by beating a level or what have you).
Hi. I make some stuff.
(MrDoubleA#3124 on Discord)

MrDoubleA's NPC Pack
rooms.lua - Quick respawn & Celeste-styled rooms
Extended Koopas

Image

More stuff: show
Shiny Medals ooo:

Image
Image
Image
Image
Image

I support:
Image
Image


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 1 guest