How do I change text with for loop

0 favourites
  • 4 posts
From the Asset Store
OpenAI TTS
$10 USD
Text-to-Speech plugin.Allows your Construct 3 project to convert written text into spoken words
  • Here is my problem, there is such a structure in my game, I write the information in the data of each image with a loop

    but when I want to print the cost on the screen, it only writes the values of the last sprite to all texts in the same way ( Image 3 )

    How can I make it so that only the value of that image is written each time, I can't find where I'm making a mistake

    Tagged:

  • From what I can see you've placed the text boxes over the store panels but in terms of code they don't relate to each other. At the moment it looks like because the text doesn't relate to any F_Store it will change all the texts each iteration of the loop and thats why it sets the final value to all.

    When you set text it has to pull the data from the related F_Store object, so this is done with conditions. It could be 'text overlapping F_Store' then it knows which one to choose, or you could set a family instance var on the F_Store object and the text object for IDs which match and then pick in that way where text.ID = F_Store.ID.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • From what I can see you've placed the text boxes over the store panels but in terms of code they don't relate to each other. At the moment it looks like because the text doesn't relate to any F_Store it will change all the texts each iteration of the loop and thats why it sets the final value to all.

    When you set text it has to pull the data from the related F_Store object, so this is done with conditions. It could be 'text overlapping F_Store' then it knows which one to choose, or you could set a family instance var on the F_Store object and the text object for IDs which match and then pick in that way where text.ID = F_Store.ID.

    thank you I didn't quite understand but I will try

    if I do it inside the for, it works, but when I want to make an operation, I can't make an operation and write it

  • Also I don't think you need a for loop, do the actions at the very top work or are they also broken ? I think you just need for each F_Store, and add the picking condition as I mentioned and should be ok.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)