How do I import list from txt non-json format

Get help using Construct 2

Post » Fri Jun 20, 2014 1:55 pm

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.
B
7
S
2
G
2
Posts: 12
Reputation: 1,382

Post » Fri Jun 20, 2014 2:46 pm

Ajax the project file, and parse through it with events. Assuming the file is formatted like this:
Code: Select all
Word
Word
Word
Word


Events to add each word the X axis of the array would be (in pseudo-code):
Code: Select all
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
B
62
S
19
G
8
Posts: 341
Reputation: 12,075

Post » Mon Jun 23, 2014 1:04 pm

Sorry for taking so long to reply here, but that is exactly what I needed, thank you so much!!! You are a legend!!
B
7
S
2
G
2
Posts: 12
Reputation: 1,382


Return to How do I....?

Who is online

Users browsing this forum: FlyingRam, jkmalau, marcinkowski and 10 guests