Save into the imported project file

Get help using Construct 2

Post » Mon Dec 01, 2014 2:36 pm

Hello fellas,

I know there's a way to download array/string/dictionary data as a file, but what I'm looking for is the possibility to save into previously imported project file. Is it possible?
B
45
S
11
G
4
Posts: 515
Reputation: 7,389

Post » Mon Dec 01, 2014 3:46 pm

xoros wrote:Hello fellas,

I know there's a way to download array/string/dictionary data as a file, but what I'm looking for is the possibility to save into previously imported project file. Is it possible?


if you export with NodeWebKit you have all action to make file an save to some folder in your computer...

but if you are looking to export on web, you can't, you need to run a php code in your server and send data with AJAX, and save your file to some folder of your server... (php do this...)
B
21
S
9
Posts: 298
Reputation: 2,967

Post » Mon Dec 01, 2014 3:59 pm

Thanks, ist's basically the same as with mySQL posts.
B
45
S
11
G
4
Posts: 515
Reputation: 7,389

Post » Mon Dec 01, 2014 4:32 pm

xoros wrote:Thanks, ist's basically the same as with mySQL posts.


you are welcome,

yes, well, with the mySQL you can store a variable into a database, this is important to load all information of the player (username, password, email...coins, jems, levels...etc...etc)

but when you need to save a big data text, like 200000 characters, you can't store on the database(you could...but is crazy)... I solved this with this step (on facebook app, but you can also make a login/registration page):

-at the first access of the user, check if exist the UID of the user in database.
- if doesn't exist, insert the UID with my data (username, password...coins "0", jems"0"...) on the database. (use method"POST") and you can also encrypt the data (there is a plugin on this forum)
- make 2 folders in my server with the UID of the user. (PHP)

this is just one file, if the user exist, just skip all of this, and if the UID exist, just load the database data.

now, when the player open a level, I do this at the first access of every level:

-at the first access of the level, check if there is a file json on a folder of the UID player with the name of the layout.
-if exist, load a AJAX.string to an array. (this load everything about the level, coins taken, terrain, etc....)
-when the player finish the level or find a save checkpoint, C2 will send a JSON string of the array with method POST on my php file, and when the php file has the data, just make a file with the name of the level in a folder of the user in .json.

now, if the file doesn't exist, just load the orginal level...this works perfect for me.... (basically the array delete the coins taken, enemy, tilemap...or something like that)
B
21
S
9
Posts: 298
Reputation: 2,967


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 5 guests