Can C2 create and save a text file?

0 favourites
  • 9 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • 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?

  • 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.

  • But can I output that data to a text file and save it outside of my game later?

  • 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

  • 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?

  • 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!

  • > 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

  • >

    > > 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

    my method works well on a browser (Chrome and such), but on a desktop, you have to use a different method in order to get it to work, and this method is for outputting files rather than inputting them.

    As for your project, I suggest you try to keep the text file outside the program and to access it by requesting the program to find the text file and phrase it to your liking, this way, you can update the text file, without having to recompile each time you want to change the text.

    Good luck on your French!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for your reply GreatProgPluto sorry for not replying sooner, busy busy all things with life! . Ideally I wish Construct had a proper database system like the Android SDK does that is held locally. I was looking at this tutorial

    https://www.scirra.com/tutorials/276/who-said-you-cant-create-a-database-with-construct2 but I am not sure even with it being web based if it will work on later versions as I do not see a "webstore" object that is mentioned.

    With your suggestion I presume you are referring to using NW.js , I did not think this would work with Android as from the Manual it only mentions desktop OS. Is this the case?

    Sorry to go a little of topic here but....

    If construct 3 had a dedicated database object I would consider moving over to it but I have not noticed one yet. I know this is more a gaming engine than an app creator but because they make it so easy but powerful to create with, it can do both if more functionality was there.

    and thank you for your encouragement on my French ! I am trying to use Construct 2 to a means of helping me learn it by writing an app that I can update with new information and use that to test me on various things like verbs and phrases but it makes the creation harder by the lack of a database engine sadly.

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