How do I read/write/edit a file (.txt)?

Get help using Construct 2

Post » Wed Jul 08, 2015 1:44 am

Hi,

I did some research but didn't find or didn't understood the answers. And some were old answers with older plugin so I got confused a little bit.
What I'd like to know is how (if we can) do we read/write/edit a text file (for examle).

The idea is to make some kind of map generator (application1) that would store values in an array, and write it in a simple text file.
Then in the "application2" (the game), we could load that map and play on it.
Is there a simple way?

Thanks.
B
6
S
2
Posts: 20
Reputation: 977

Post » Wed Jul 08, 2015 5:43 am

Image
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Wed Jul 08, 2015 2:57 pm

Thanks, it's a bit clearer now.
But can we save the file within the project folder? more like just editing it or saving over it... instead of "downloading" the info.
B
6
S
2
Posts: 20
Reputation: 977

Post » Wed Jul 08, 2015 3:07 pm

Not really.
If you want users to be able to store some level data etc on your servers, then you need to work with a database and for example send the data to it by calling a php script that does the data entry into the database.
If you want to store it locally without any sharing between users, you can use the localstorage. In this case it would make sense to combine the map editor and game itself into one app, since then it would use the same local storage.
If you want users to be able to share their creations you would need a database again, except if you are going for an inconvenient solution like users needing to copy and paste long strings of text into their game.
At least that are the options that I see.

Node Webkit has a file writing function, but it did not work for me, so meh... won't cover that here.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Wed Jul 08, 2015 3:31 pm

I see. Thanks for the explanation. I think I'll do with the download thing then. That editor is meant for me only to generate some inital maps for my game.
B
6
S
2
Posts: 20
Reputation: 977


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 44 guests