Best way to check stored values from input?

0 favourites
  • 7 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • Hello all, its wonderful day.

    I am trying to make a simple game as following:

    1.) On start of layout, generate a random number and store it in a global variable

    2.) Show that number and then asked the user to say the number in Spanish

    3.) I want to validate they said the number correctly (WHATS THE BEST WAY TO DO THIS?)

    My thought here was to somehow store all the words which I would use in the game in a table or database of sorts and then check against that value but not sure how to do that.

    I also thought about storing the correct values as global variables but that sounds really inefficient

    4.) Once they get the number correct, generate a new number and repeat (whats the best way to do this?)

    I tried to create a global variable which checked whether the answer was correct but then not sure how to loop or increment in an event driven way.

    I am grateful for the help!!!

    Thank you

  • Your post is so big but still doesn't really say what you want help with. Do you mean you want to check if a user speaks correct Spanish?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • To be more clear, I am able to get the voice input just fine, but I want to validate whether the input is correct.

    So creating an individual condition for each word sounds like a horrible and inefficient way to do it. Especially since the numbers are being randomly generated.

    what I am asking is, how can I check the input to see if its correct.

    For example, I show the number 1, I get the voice input as "uno". How can I check that this is correct other than hardcoding that 1 = uno? Wouldnt a table or database work for this?

    does that make more sense?

  • The best way could be to use an array and store the answers. If it's always going to be numbers then you don't need to store the numbers and instead use the row number of the array as the number with the answer stored. If the question is going to be eventually something other than a number then yes store question and answer using two columns.

    To pick the random number you would generate using something like floor(random(100)) which picks a random number from 1 - 100, then grab the expected answer from array position - array.at(num) where num is the number you just generated. So if the number is 18, array.at(18) picks the answer from row 18. If you stored both the question and answer then you'll need to also pick the column so array.at(num,0) is question and array.at(num,1) is the answer.

  • lionz thank you for the response, how would I do the column row storage? Does Construct3 have some native storage or table options to do this?

    Thank you again

  • Yes it's called an 'array file' on the side bar and looks like an excel sheet with rows and columns. You can fill it out there and load this file into the array on start of layout using AJAX, request file then load into array ajax.lastdata

  • For anyone who finds this thread, I was able to solve my issue by using a "Dictionary" object. I used key-value pairs for the words/phrases and their translations and it worked perfectly

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