C
ChaosX2
Guest
Hello,
I'm having trouble updating some variables for my npc's talk code. I set the data for the variables within the creation code so I can use one npc object for all the npc's in the game, but when I make certain changes, the variable won't update to reflect the change. Here's how it works.
Above is an array of arrays of text. I use the variable page to access which one I want and then the variable phrase to iterate through the chosen array of text. I also use one to showcase which object is speaking. In the code snippet below, the npc talks first and then the player. the first position in the array is the name of the object speaking. The second position in the array is the sprite index to use for the face portrait on the text background. The third position in the array is the image index
The two code snippets are in the creation code event of each npc object. My game is an RPG and you can change your avatar to any of the characters in the party. When you do, charDisplay[charDB.NAME] updates to display the proper name and playerAvatar will display the proper image index for the character.
If I take the same two code snippets above and place them in a user event and call them, the variables will update to display the character's name and portrait I'm using, but if I try to reassign the values again to the array a different way (in the same user event), the values do not update.
Here's what I tried...
It doesn't update. I need some organic way to set the data because not every npc will have the same length of text or number of speakers. Any help is much appreciated and I hope I explained this clearly!
I'm having trouble updating some variables for my npc's talk code. I set the data for the variables within the creation code so I can use one npc object for all the npc's in the game, but when I make certain changes, the variable won't update to reflect the change. Here's how it works.
Code:
myText = [
[Hello world, this is a sentence to test my text, This is the next phrase spoken after pressing the A button], [I speak this text after you complete a small quest]
]
Code:
speakers = [
[id.name, noone, 1], [charDisplay[charDB.NAME], spr_facePort_talk_happy, playerAvatar]
]
If I take the same two code snippets above and place them in a user event and call them, the variables will update to display the character's name and portrait I'm using, but if I try to reassign the values again to the array a different way (in the same user event), the values do not update.
Here's what I tried...
Code:
for(var i = 0; i < array_length_1d(speakers); i++)
{
var speakerData = speakers[@i];
names[i] = speakerData[0];
portrait_sprite[i] = speakerData[1];
portrait_emoji[i] = speakerData[2];
//scr_to_array outputs an array of it's arguments
speakers[i] = scr_to_array(names[@i], portrait_sprite[@i], portrait_emoji[@i]);
}