Pulling text data from an array and pasting it into four separate text boxes without it repeating?

1 favourites
  • 5 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
  • Boring title, I know.

    Really I have two issues here that I can't wrap my head around:

    1. Pulling text data from an array and pasting it into textboxes.

    This is my eventsheet and the array, but it is just giving me "0"s:

    2. Randomizing this data in a non-repeating fashion.

    This eventsheet works in my head, but not in reality (I know it's not pulling from the array yet, but since I was struggling with the array, I was just trying to get non-random numbers first):

    Thanks for your time! Please let me know if this message is not clear.

  • Hey,

    the array is not loaded properly because AJAX is asynchronous and is not available the instant it is called.

    As for the randomized non-repeating, you could set the data from the array at random and then delete that particular row from the array so it cannot be picked again. If you need to keep the array intact, you could just use a second array with the same data.

    Also I recommend to use floor(random(1, array.height+1)). This is a must with the approch above since the array height changes. But generally it is much more convenient since if you add a row to your array you don´t have to adjust all the events accordingly.

  • WackyToaster Thank you so much foe that! It solved the array pulling problem. And I will test out the randomization idea very soon, but I think that it might be prudent to ask the following question first, because it will probably effect the way in which I randomize the answer selection:

    How can I make sure that one of the answers matches the variable/name/slide of the presented card?

    Right now I have one sprite that contains all of the cards, organized into three animations (one for each type), with five frames (one for each card). This matches the array that you can see in the picture.

    Thank you for your help so far!

  • I would have a third column that marks the correct answer.

    Eg:

    Pets:Cat:0

    Pets:Dog:1

    Pets:Rabbit:0

    Pets:Mouse:0

    Then you can check to see if it's correct. It would also allow you to have more than one correct answer if you wanted to.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • graham-s Super smart! Thank you.

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