Displaying Items in Evented Menu

(Hi! First thread on here, so please correct me if I posted this in the wrong area.)

I'm working on a small-town simulation game, and for the most part it contains a lot of evented menus with variables, conditional branches and pictures (bc scripting is a pain). However, I'm kinda running into an issue with most of them of how can I display "items" in order as the player encounters

For example,
Screenshot 2023-08-30 181439.png


I have a menu that just displays relationships/info with each character the player meets,

It would work like this:
The player interacts with new NPC > NPC gets added to the next empty slot that's available (would be an asset/picture of the character replacing the empty picture-holder), and so on until pages are filled.

Would this be possible to event with variables/branches/etc, or would I have to manually event each character to an assigned slot instead?

(Thank you to whoever took the time to read this, any help or guidance is very much appreciated 😀)
Declare one of your control variables as an empty array at the beginning of the game, e.g. NPCs = []
Then every time you talk to an NPC for the first time push their name into the array. Then populate your menus with the NPCs by array order.
Declare one of your control variables as an empty array at the beginning of the game, e.g. NPCs = []
Then every time you talk to an NPC for the first time push their name into the array. Then populate your menus with the NPCs by array order.
Thank you for the response! Though, I’m a bit confused of the process, could you provide some more detail of what you mean? Again, thank you!
I don't know how you set up your custom menu so without the code for how it is currently populated I can't advise how to edit it.

If you want the name of the first NPC you talked to use $gameVariables.value(45)[0]. The second would be $gameVariables.value(45)[1] and so on
I don't know how you set up your custom menu so without the code for how it is currently populated I can't advise how to edit it.

If you want the name of the first NPC you talked to use $gameVariables.value(45)[0]. The second would be $gameVariables.value(45)[1] and so on

Is it fine if I attach my menu event page here then?
Is it fine if I attach my menu event page here then?
Yes, if you want advice on how to edit your menu you need to show how you're currently doing it.
Yes, if you want advice on how to edit your menu you need to show how you're currently doing it.

Here's what I have so far for the main event, but at the moment it just interacts kinda as a mock-up, If I need to provide more context I can
image(2).png
Here's what I have so far for the main event, but at the moment it just interacts kinda as a mock-up, If I need to provide more context I can
This is just code for a blank menu. There is no code to actually update the blank menu slots. What information do you want to show when the empty slot is updated?
This is just code for a blank menu. There is no code to actually update the blank menu slots. What information do you want to show when the empty slot is updated?

Basically, a graphic of said character takes place of empty graphic. An example of what I mean is how Pokemon teams contain 6 slots, and when you catch a new one, it's placed in the next available slot instead of a predetermined order.

This was the system from a bit ago I had if I was going to manually assign characters to a personal spot with switches and conditional branches instead:

1. Character Interaction on the first event page
sally.png

2. The common event that would display the first page and slots
woop.png

3. would show like this
sallypage.png


Instead of working with a fixed order, I was wondering if there was a way I could instead do it dynamically :LZYdizzy:
Instead of working with a fixed order, I was wondering if there was a way I could instead do it dynamically
Yes, it just requires scripting. You basically need to keep a list, or array, of every NPC you meet in the order you meet them. Whenever you talk to an NPC, their name gets added to the list. You use the self switch after talking them for the first time (as shown in my screencap above) because otherwise every time you talk to them you'll add their name to the list again. From there you can call on this list to return a name from position #X, this is called an array index.

At the beginning of the game, declare a control variable as an empty list/array.
Control variables #0045 = [];

After you talk to a few people, the array will look like this:
["Ema", "Harold", "Therese"]

To get the first person on the list's name you call the array index (starts at 0)
$gameVariables.value(45)[0]

3. would show like this
View attachment 275214
Ok, so you have two elements that are variables: a picture and a name. But you have another variable: the length of the list itself, i.e. how many entries.

You are going to need to go through the list (loop through the array) and add an entry to your menu for every name on the list. It will look something like this:

JavaScript:
for (i = 0; i < $gameVariables.value(45).length; i++){
    //draw box at position on screen
    //draw picture in the box at x position , e.g. $gameVariables.value(45)[i] + ".png"
    //add NPC name at y position, e.g. $gameVariables.value(45)[i]
}
i.e. "For every index on the array until you reach the end of the array, draw the box, draw the picture of index i, add the name of index i, then move on to the next item in the array.

E: Actually it might be easier than that. If there are always three blank boxes on the page and you just need to fill them in you can just change the image and text inside them to variable references to the positions on the array.
Yes, it just requires scripting. You basically need to keep a list, or array, of every NPC you meet in the order you meet them. Whenever you talk to an NPC, their name gets added to the list. You use the self switch after talking them for the first time (as shown in my screencap above) because otherwise every time you talk to them you'll add their name to the list again. From there you can call on this list to return a name from position #X, this is called an array index.

At the beginning of the game, declare a control variable as an empty list/array.
Control variables #0045 = [];

After you talk to a few people, the array will look like this:
["Ema", "Harold", "Therese"]

To get the first person on the list's name you call the array index (starts at 0)
$gameVariables.value(45)[0]


Ok, so you have two elements that are variables: a picture and a name. But you have another variable: the length of the list itself, i.e. how many entries.

You are going to need to go through the list (loop through the array) and add an entry to your menu for every name on the list. It will look something like this:

JavaScript:
for (i = 0; i < $gameVariables.value(45).length; i++){
    //draw box at position on screen
    //draw picture in the box at x position , e.g. $gameVariables.value(45)[i] + ".png"
    //add NPC name at y position, e.g. $gameVariables.value(45)[i]
}
i.e. "For every index on the array until you reach the end of the array, draw the box, draw the picture of index i, add the name of index i, then move on to the next item in the array.

E: Actually it might be easier than that. If there are always three blank boxes on the page and you just need to fill them in you can just change the image and text inside them to variable references to the positions on the array.

Ok, so I'm starting to get a better understanding of what you mean now after looking a bit into arrays and kinda getting somewhere now! but I'm just a bit stuck on the calling "$gameVariables.value(45)[0]" and Javascript example, like how would I utilize that within the menu? I'm mainly using pictures graphics for the names/icons instead of elements like text scripts (unless I misinterpreted what you meant)
Ok, so I'm starting to get a better understanding of what you mean now after looking a bit into arrays and kinda getting somewhere now! but I'm just a bit stuck on the calling "$gameVariables.value(45)[0]" and Javascript example, like how would I utilize that within the menu? I'm mainly using pictures graphics for the names/icons instead of elements like text scripts (unless I misinterpreted what you meant)
$gameVariables.value(45)[0]
will return the first name in the array. You would have to name the picture files Ema.png, Harold.png, etc. So then, in the place where the picture goes you would put $gameVariables.value(45)[0] + ".png" to get Ema.png for example, if she was the first person you talked to.
will return the first name in the array. You would have to name the picture files Ema.png, Harold.png, etc. So then, in the place where the picture goes you would put $gameVariables.value(45)[0] + ".png" to get Ema.png for example, if she was the first person you talked to.
Would this be the right usage then of the command?
Would this be the right usage then of the command?
No because it's not a command, it's a variable reference. It's meant to be used inside a script call instead of a picture name, e.g. Ema.png, to show a picture.
No because it's not a command, it's a variable reference. It's meant to be used inside a script call instead of a picture name, e.g. Ema.png, to show a picture.
So as this?
$gameScreen.showPicture($gameVariables.value(45)[0] + ".png", 0, 0, 100, 100, 255, 0);

E: Okay so after a bit of messing around, I finally figured out to implement what you told me into the menu and it works exactly how I needed it to 😀!! Thank you so so much for the help and information and your time! It works perfectly for my system.

Original thread: https://forums.rpgmakerweb.com/threads/displaying-items-in-evented-menu.160774/