Saving data to file possible in C2?

Discussion and feedback on Construct 2

Post » Sun Feb 17, 2013 9:07 pm

Hi guys, I really am sorry if you have all heard this question before.. but i'm just trying to clarify.

I bought C2 today as I tried the demo and was instantly impressed! I'm used to making games in Multimedia Fusion 2 by Clickteam and, though the support and functionality is great, Construct seemed to make some things so much easier, or even do things that just were not possible on MMF2.

Anyway.. I'm a little gutted as after quite alot of research it seems that loading / saving data to the file system is.. 'Impossible' due to the fact that it is purely HTML5? I may be wrong here but after looking around to day this seems to be true. After looking further it seemed Construct Classic could do this?

I like to build my own level editors for my levels, it just works better for me and to be honest if there is absolutely no way of saving them (I don't want to just save the data in a session, or webstorage) then Construct 2 for me, was a waste of money. But I guess that is my fault for not looking into it enough.

The guy over at http://www.konjak.org/ apparently uses Construct now.. And he seems to be loading in level data from local files saved on the hard disk.. So how is he doing that.. Or was that made with Constuct Classic.. If that is the case, I really should be using that.

Any answers appreciated, sorry for my ignorance!
B
3
Posts: 4
Reputation: 558

Post » Sun Feb 17, 2013 9:16 pm

Your little bit of research should have been a little bit more, but I guess that's where this thread comes in :P

Don't dismay, saving and loading information is entirely possible with C2 using WebStorage. Don't let the name fool you, though, you can use WebStorage with offline apps, too, including Node-Webkit (desktop) and CocoonJS (iOS/Android).

Everything is covered in the manual entry, and here is a super basic example I made for another user recently.

Oh, I see that you have already seen WebStorage. Then what you want is "local", not "session" storage. That's possible too as you can see in my example.GeometriX2013-02-17 21:18:40
B
56
S
15
G
10
Posts: 910
Reputation: 11,972

Post » Sun Feb 17, 2013 9:25 pm

That was a quick reply thanks Geometrix! I did notice before that WebStorage isn't exactly what it sounds like and the data is actually stored on the local machine, but for making a level editor, you would want to be able to 1. create the level, 2. click save to open a dialog box, 3. save the file somewhere on the hard drive. And then the actual game can read from that file and load in the level array data. Is that kind of thing supported?
B
3
Posts: 4
Reputation: 558

Post » Sun Feb 17, 2013 9:40 pm

As far as I understand it, XML and AJAX can do half of what you want (loading files), but not actually create new files, but my knowledge of those functions is pretty limited so I wouldn't be able to give you a definitive answer.

I suppose you could use WebStorage to save your data from your editor and then retrieve that data as necessary, but that would be a bit cumbersome for your needs.
B
56
S
15
G
10
Posts: 910
Reputation: 11,972

Post » Sun Feb 17, 2013 9:47 pm

Hmm.. seems like this plugin pretty much does what I would like: http://www.scirra.com/forum/plugin-filesaver_topic49803.html as far as letting me choose some where on the file system to save a data file (If run as an executable on windows) Only thing is now trying to compress that data, but thats a different story entirely!! Thanks for your help by the way!
B
3
Posts: 4
Reputation: 558

Post » Mon Feb 18, 2013 10:32 am

From your level editor you can download the contents of an array as a json textfile (array->download). In preview mode your browser will download it when you trigger it.

You then import the json textfile into your game in C2.

You then set your array to load the file.

https://www.scirra.com/manual/108/array
B
29
S
8
G
4
Posts: 61
Reputation: 6,205

Post » Mon Feb 18, 2013 11:43 am

Using a browser-based technology requires a bit of a mental shift: you can save data permanently, and download files to disk, but it just works a little differently. You can't do the traditional read-and-write-files arbitrarily, because that's a huge security risk in a browser.

WebStorage provides permanent save storage, even when offline. You can download Array and Dictionary data as JSON for level editors, and AJAX them as project files to load them dynamically.

We might be adding more storage features in future, but I think everything's there - it's just a different workflow.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Sun Mar 17, 2013 5:45 pm

Hello,
And sorry if my question is silly...
Is it possible to download audio files (by URL) and then import them?
The aim is to play it with "play by name".

Thanksaktarus2013-03-17 18:26:05
B
9
S
1
Posts: 20
Reputation: 1,242


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 13 guests