Can C2 create and save a text file?

Get help using Construct 2

Post » Sat Jun 21, 2014 4:43 pm

Not sure if I'm being dumb, but is there a way in C2 to save a text file to disk from within your game? Does it have load/save dialogs etc?

I'm not talking about in the project, but while the game is running. Could the game create a bunch of text and output it to the PC disk?
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Sat Jun 21, 2014 5:20 pm

Yes, WebStorage allows you to store game data. no need for dialogs, that all can run in the background but you can make your own.
B
20
S
3
Posts: 67
Reputation: 1,074

Post » Sat Jun 21, 2014 6:12 pm

But can I output that data to a text file and save it outside of my game later?
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Sat Jun 21, 2014 6:34 pm

Yes, WebStorage works like a Cookie. It will save a little text file on your pc. The next time you load your game it will open that file.

https://www.scirra.com/tutorials/526/ho ... -savegames
B
20
S
3
Posts: 67
Reputation: 1,074

Post » Sat Jun 21, 2014 7:18 pm

But is it possible, for example, to make a text file that I can save and then access from Windows afterwards? E.G I make a text file with my game, save it to the desktop and then I can open it up in Notepad?
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Mon May 15, 2017 1:29 pm

farflamex wrote:But is it possible, for example, to make a text file that I can save and then access from Windows afterwards? E.G I make a text file with my game, save it to the desktop and then I can open it up in Notepad?


I know i am answering an old question but it might help for someone in the future,

If you add the "Browser" object to the project, there is an action you can add to the event sheet called "Invoke download of string", which is usually reserved for downloading .JSON files for all sorts of things, now im not too sure if this feature is intended, but if you want the game to download regular .TXT with the text of your choice, simply add the string you want in the "String" box, change the MIME type to "text/plain", and replace in the filename the ".json" to ".txt", hope that helps!
B
5
Posts: 3
Reputation: 245

Post » Tue Jun 13, 2017 7:52 pm

GreatProgPluto wrote:
farflamex wrote:But is it possible, for example, to make a text file that I can save and then access from Windows afterwards? E.G I make a text file with my game, save it to the desktop and then I can open it up in Notepad?


I know i am answering an old question but it might help for someone in the future,

If you add the "Browser" object to the project, there is an action you can add to the event sheet called "Invoke download of string", which is usually reserved for downloading .JSON files for all sorts of things, now im not too sure if this feature is intended, but if you want the game to download regular .TXT with the text of your choice, simply add the string you want in the "String" box, change the MIME type to "text/plain", and replace in the filename the ".json" to ".txt", hope that helps!


Hi GreatProgPluto

I stumbled across this thread and your reply while trying to achieve this myself. Not sure if my goal is the same, but currently my project is to learn French and when I add new data , I have to open the text file from within the project via construct 2 add the new data save it back and then re-compile the project for my own use.

Currently I had added quite a lot of data to these text files and it becomes very time consuming to do it this way. Can you use this method you have stated for this purpose and if so how, as I have tried to do as you have stated but I cannot get it to work
Regards

TimCS
B
23
S
8
Posts: 132
Reputation: 1,921


Return to How do I....?

Who is online

Users browsing this forum: PROxMTswatTR, sean080 and 39 guests