Select lines from a .txt file to display

0 favourites
  • 6 posts
From the Asset Store
A set of retro 16-Bit Neon UI elements to make your menus pop!
  • Hi,I'm making a quiz game and to make it easier to get the questions in the game I am usinge AJAX to load a .txt file.

    I have so far managed to get the .txt file loaded and the first question to display in my text box by setting text to AjaxLastData.

    Even that took me ages to work out because I am such a noob.

    Is there an easy way to set the text to specific lines in the .txt so I can just have a list of questions that can be selected?

    Please don't tell me I need an array because that is definitely beyond me!



  • AjaxLastData contains the integrality of your text file. You will have to parse it to retrieve the lines you want. I guess you could tokenize the data with the "newline" character (using tokenat). But it will be practicable only if you have one question per line. Otherwise you might want to take a look at XML.

  • I suggest you either using a special char and tokenate at it

    Imagine this:


    Blah, blah, blah


    1. X

    2. X

    3. X



    You can get first question by using tokenat(yourtext,1,"#").

    And, inside the first question, you can get first answer by finding newline&"1.", second by finding newline&"2.", etc.

    I use a similar scheme in my game "caballo", where the "question" text is inside a textbox (I made that before files were avalable)

    You could use XML or JSON instead if you want to make something more standarised, of course.

  • I just want to add I've uploaded to the arcade the program I use to debug my xml files, just in case you decide to use XML.

    It is here

  • Thanks Arcalaus- I think that will do the trick. I don't even need the answers- it's all very simple.

    I'll be setting it up on Monday- hopefully this will be the end of this thread!

    Cheers ;)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Cheers Magistross- the questions are all on new lines so a newline parse will be fine!

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