Can you write and read a text file?

Get help using Construct 2

Post » Mon Aug 13, 2012 10:22 am

Is there a way I can get Construct 2 to write to text file (such as .txt) as well as read from it?
B
13
S
4
Posts: 117
Reputation: 2,242

Post » Mon Aug 13, 2012 11:04 am

You can use the AJAX behavior, but It only works on files stored on the same HTTP the game is hosted on, it won't be able to call from other domains :)
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

Post » Mon Aug 13, 2012 12:07 pm

If you made a server side script, there's no reason you couldn't also POST new data to the server with the AJAX object.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Mon Aug 13, 2012 6:44 pm

I don't think my question was clear that time.

Is there a way I can get Construct 2 to write a text file on my computer? Then after the file is written, is there a way I can place that file into the project, so it can read it later?

Edit: Never mind! I figured it out! :P
Thank you for pointing me to the AJAX object!Zero62012-08-14 02:37:58
B
13
S
4
Posts: 117
Reputation: 2,242

Post » Wed Nov 19, 2014 9:48 pm

I am trying to do this to, but I can't seem to figure it out. I see how you can use AJAX to write to a PHP file on a server, but is there a way to write directly to a local or network drive?
B
7
S
1
Posts: 15
Reputation: 951

Post » Tue Dec 02, 2014 3:34 pm

Hey Ferguson, i'm trying to figure this out as well... Any luck?

@Zero6 would be great if you could share your solution?
B
7
Posts: 24
Reputation: 318

Post » Tue Dec 02, 2014 4:22 pm

Well I did discover something. It seems you can read or write directly to a txt file from Construct 2, the limitation seems to be that it needs to be exported as a Node-Webkit. You need to add the Node-Webkit actions first and use the "Write file" or the "ReadFile" options.

It seems you can also Move, Copy or Delete files as well.

The other caveat is you need to export the file and run it from the exported folder for these features to work. They don't seem to function in the Preview Browser.

I hope that helps.
B
7
S
1
Posts: 15
Reputation: 951

Post » Wed Dec 03, 2014 8:48 am

Thanks Ferguson, I'm purchasing a full business licence this week which should allow me to play with the Node Webkit stuff...

I'll let you know how I get on.

Many thanks for your reply,

Matt.
B
7
Posts: 24
Reputation: 318


Return to How do I....?

Who is online

Users browsing this forum: GUN and 20 guests