List being repeated after every scene transition

chongyunxiang

  • Posts: 270
Hi,

I have an issue with the items in my list being repeated each time I change scenes. Is it because of the Created events?

I want the current food preference to show just 1 set of type of food list, instead of it being repeated each time I change scene.

Luyren

  • *
  • Posts: 2381
Your list is a game attribute. By definition they retain their values through scene transitions.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

chongyunxiang

  • Posts: 270
I want it to retain it's value, but not being created multiple times like in the video. My other list game attribute don't have the issue and doesn't duplicate.

I'm able to change the items in the List, but each time the scene change, the items will be duplicated. If I change the scene 3 times, it'll show Chicken Chicken Chicken. When the food preference change, it'll be Beer Beer Beer. So if I change scene again, it'll show 4 times. I wonder what's causing it to display each time I transit scene.

Luyren

  • *
  • Posts: 2381
You already answered your own question: you are adding items in the created event of your scene. You can simply configure the initial items under Settings > Attributes for your game attribute.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

chongyunxiang

  • Posts: 270
Ah, I kept thinking that it was the CurrentFoodPreference created event that was the problem, but it was actually the AddFood when created that was causing the duplicate. That fixed the problem, just that the emoticons tied to the FoodPreference failed to display emoticons (not sure why), but I fixed that by using Code:Actor.getName(). It seems to be working properly now, thanks!