How do I Random Text from Array?

0 favourites
From the Asset Store
OpenAI TTS
$10 USD
Text-to-Speech plugin.Allows your Construct 3 project to convert written text into spoken words
  • I have searched whole internet but cannot find exact info for this step. How I can just simply Load random question from array and display it on screen?

    I have array created already. Anymore I need to get my game pick randomly on start of the layout one text from array.

  • One trick is to pick a random index, from the Width of the array, and delete it from the array. Each iteration will only pick from the remaining items.

    http://www.blackhornettechnologies.com/Construct2Stuff/RandomStringArray.capx

  • Thx for your quick reply. This was good sample. Still I cannot solve my problem which was near by your solution.

    Now I have problem that my Array has values loaded from textfile. But my game is appending text as numbers.

    Something is wrong. Someday I will laugh to this but today I don't know how to use arrays smoothly

    Don't pay too much attention to commentlines as I have moved few actionlines places so it's messy.

  • Skebab This tutorial might help you

    https://www.scirra.com/tutorials/1418/trivia-game

    https://www.scirra.com/tutorials/1417/r ... -as-arrays

    Thank you ! I think these helped me to clear my ''code''.

    Now I have done I think everything I can as following your Trivia Tutorial. I dont have any answer options on my game so I tryed to find out what I dont need.

    Now when I am debugging my game I will find every card on their own Array cells. But I cannot set text to be visible. Maybe you can find out why?

  • Skebab

    1st Have you created any Text on layout? if not how you will see it

    2nd If you did create Text on Layout, did you set property of Text to be VISIBLE

    3rd If you did not create Text on Layout how can you see the TEXT?

  • Skebab

    1st Have you created any Text on layout? if not how you will see it

    2nd If you did create Text on Layout, did you set property of Text to be VISIBLE

    3rd If you did not create Text on Layout how can you see the TEXT?

    Thx for your reply Lordshiva.

    1) Text is on Layout and set Visible

    2) Debug mode shows that there is all values nicely in own cells in arrays

    3) I have succeeded to get system randomly pick one of the values from array

    PROBLEM) I just cannot get this value showed at TEXT on layout ????

    Instead what I have got working is that I get only numbers showing in layout where text should be showen by editing code.

    Sometimes I have even got first text value showed in layout but if system pick up some other cell than array nmbr. 0 it will show only blank.

    Here is my code now:

  • Post a CAPX. It's too hard to debug by screenshots.

  • blackhornet is quite right my friend. When I look at your code I thought you have not any text on Layout. I am sorry about that

  • Okay I dont know other way to share capx, I hope this will work:

    drive.google.com/drive/folders ... sp=sharing

    Thank you very much for taking me forward with this! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" />

  • Skebab most welcome we are here to help

  • Skebab your link is broken it says

    400. That’s an error.

    The requested URL was not found on this server. That’s all we know.

  • New users can't post valid links. I think you can get a way with just putting # at the beginning of the address. Forum users will know how to deal with it.

  • Hi,

    Okay I am really glad you help me.

    Try this URL, will it works better?

    #https://drive.google.com/drive/folders/0B21BkWRH8AF0OVpxYlc3d1BkU2c?usp=sharing

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Now when I am debugging my game I will find every card on their own Array cells. But I cannot set text to be visible. Maybe you can find out why?

    Probably because the textobject is way to small.

    If you share a project. Plz save it as a single file.

    File menu > Save As Single File.

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