How do I populate a list from a text file

Get help using Construct 2

Post » Mon Feb 15, 2016 8:17 pm

I am looking to use a text file to generate a list on the start of a layout. I had a search on the forums but couldn't find anything. I am currently using a list object and manually adding all the lines. The text files are just lists like:

"One
Two
Three
Four"

I can have the text file in any format but as above is the easiest to take it from the excel data. The lists will be around 20-30 eventually and the thinking is to make it easily changeable.

Anyone able to help?
B
37
S
10
Posts: 188
Reputation: 3,818

Post » Mon Feb 15, 2016 8:21 pm

You can add the text file as a project file, use AJAX to load it, and use tokenAt and tokenCount with a for loop to split it up into individual words that you can add to the list.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,610

Post » Tue Feb 16, 2016 2:50 am

I typically search the tutorials before the forums. Lots of people have written stuff on lists. Here's one that should help: https://www.scirra.com/tutorials/1417/r ... ays/page-1
B
4
S
1
Posts: 3
Reputation: 276

Post » Tue Feb 16, 2016 9:34 pm

B
55
S
29
G
19
Posts: 1,520
Reputation: 25,610

Post » Fri Feb 19, 2016 9:39 pm

Hi @ramones and @Voodude

Thanks for the links and tips. Managed to get it all working great. I didn't realise until the example that you can use Newline which was handy as my lists are exported from excel!

My next challenge is updating the total price. It takes a quantity and multiplies by a rate. Trouble is I am using the condition if Rate / Quantity boxes are changed to trigger the total text update. It seems it works 90% of the time but sometimes it lags and doesn't update. Inserting a wait 0.1s at the top before calculating seems to make it reliable but ideally I do not want this =(
B
37
S
10
Posts: 188
Reputation: 3,818


Return to How do I....?

Who is online

Users browsing this forum: angryvel760, chrislechat, eryson27, ismael123 and 3 guests