Online save files

Get help using Construct 2

Post » Mon May 19, 2014 6:57 am

I've considered using my website to store player's save files (basically "cloud saves") so they can pick up where they left off on another computer, or have multiple save files that they can switch between.

In Construct 2, a player's entire save file is stored as a Hash Table (using a 3rd-party plugin) that can save/load to a JSON string. On my website, I can store/load a string to/from a flatfile (using player's name as filename).

How would I bridge the two? Here's what I envision:

1. When user starts game, they are prompted to create an online save or play locally.
2. At the main menu, they can press a button to create an account (upload local save to web), or log in (download remote save).
3. If user is logged in, they will automatically upload their save when it changes.

Downloading:

1. Game sends username and password to server
2. Server sends back JSON file with valid data if correct login, or blank otherwise
3. Game reads file and prompts for re-login (if invalid) or loads save (if valid)

Uploading:

1. Game sends username, password, and JSON to server
2. Server saves file if valid, or rejects if invalid (does not respond to server)

If a local save exists, game uses that to load/save. If registration (name/pass) also exists, game will upload to that.
Game will only download from server when logging in (or changing accounts).

Is this possible? How do I send messages between the game and server?

I am familiar with PHP, JavaScript, etc, so I expect a web developer's perspective.
B
9
S
1
Posts: 98
Reputation: 853

Post » Mon May 19, 2014 10:51 am

Use Ajax plugin.
B
31
S
10
G
3
Posts: 310
Reputation: 6,056

Post » Mon May 19, 2014 1:38 pm

Ahh, I didn't see the LastData expression in there before.

Does this plan sound feasible and doable, then?
B
9
S
1
Posts: 98
Reputation: 853

Post » Mon May 19, 2014 3:28 pm

looks like a well thought plan and is absolutely doable with the standard plugins delivered with C2.
As stctr said, Ajax is all you need for this (in addition to your server side scripts in PHP, Perl, or whatever)
B
44
S
10
G
8
Posts: 437
Reputation: 6,463

Post » Mon May 19, 2014 11:07 pm

Yes it is doable very easy.
B
31
S
10
G
3
Posts: 310
Reputation: 6,056

Post » Wed May 21, 2014 2:06 am

Well, that felt a lot more painful than it needed to be, but I got it working! HUZZAH!

If anyone feels like trying it out, you can do so at http://www.carnageinspace.com

If anyone wants to make their own online save files, I'll freely provide snippets of the Construct and PHP code used to make it.
B
9
S
1
Posts: 98
Reputation: 853


Return to How do I....?

Who is online

Users browsing this forum: Exabot [Bot], Kin, ratboy3, tinhofiel and 39 guests