How do I import list from txt non-json format

0 favourites
  • 3 posts
From the Asset Store
Template for scrollable list, fully documented in comment and video
  • Hi all,

    I am working on a project, I have been given a list of words in a txt file and want to import them into construct (already have the txt file inside the project as a project file) and put them into an array or something of that sort so I can choose random words to display.

    The are all separated by a newline, but I am not allowed to edit the file to be in json format. I have been allowed to use whatever software I wish, so decided on Construct.

    Is this possible?? Spent a few hours trying to figure it out.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ajax the project file, and parse through it with events. Assuming the file is formatted like this:

    Word
    Word
    Word
    Word[/code:3nksfzll]
    
    Events to add each word the X axis of the array would be (in pseudo-code):
    [code:3nksfzll]
    On start of layout: AJAX request the project file
    On Ajax request complete: Set array size to 0,1,1
       Repeat tokencount(Ajax.LastData,newline): Push back tokenat(Ajax.LastData,loopindex,newline) on X Axix
    [/code:3nksfzll]
  • Sorry for taking so long to reply here, but that is exactly what I needed, thank you so much!!! You are a legend!!

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