(changed) Webstorage issue in preview.

Get help using Construct 2

Post » Sat Jun 28, 2014 6:40 pm

Hi again,

I was wondering if there is a way for a player to delete save states from a game. Lets say for example, you have three save game files using the "Save" and "Load" functions: e.g. mysave1, mysave2, mysave3.

However, the player wants to restart from scratch and wants to delete a file, I don't see anything in the System settings to make this work, or am I missing something? I'm trying to implement a save system and it donned on me that I can't find a way to allow the player to delete save states.

Thanks!
Last edited by GG-Works on Sun Jun 29, 2014 5:32 pm, edited 1 time in total.
Image
B
15
S
4
G
3
Posts: 119
Reputation: 3,787

Post » Sat Jun 28, 2014 7:17 pm

Right now my idea for a work-around is to make a save function similar to that from Sonic 3&K where you can always start a new game, but you can overwrite save files if you so please.
Image
B
15
S
4
G
3
Posts: 119
Reputation: 3,787

Post » Sun Jun 29, 2014 5:22 pm

Actually, scratch deleting save states. I did find a work around where the player can create a new game, which erases arrays and other instances and variables to emulate starting over. The three save slots I've made will use the Save/Load states.

However, I'm looking at a couple tutorials on saving arrays:
saving-and-loading-an-array-to-webstorage-capx_t68859?start=20
https://www.scirra.com/tutorials/307/ar ... ers/page-3

Image

Here's the example, I thought I was following the directions to the letter, but when I restart the preview on Node Webkit it acts like nothing is there. Is it just a preview thing and I need to export it to truly test it out? The capx is 200mb and I couldn't upload an attachment so all I have is this screenshot. Hope that explains it.
Image
B
15
S
4
G
3
Posts: 119
Reputation: 3,787

Post » Sun Jun 29, 2014 5:51 pm

Remove the quotes from "SaveArray.AsJSON" so it's just SaveArray.AsJSON should do it (otherwise the only thing saved is the literal text: "SaveArray.AsJSON"

Hope that helps :)
"Construct 4 lets YOU make advanced games! (but not play them)" Construct Classic - Examples Kit
B
113
S
39
G
17
Posts: 2,184
Reputation: 19,217

Post » Sun Jun 29, 2014 6:25 pm

Jayjay wrote:Remove the quotes from "SaveArray.AsJSON" so it's just SaveArray.AsJSON should do it (otherwise the only thing saved is the literal text: "SaveArray.AsJSON"

Hope that helps :)


Ah, I wasn't supposed to put that part in quotations then? Thank you so much, this frustrated me for the most part of yesterday! I think it works now, I might even go back and replace save states with webstorage. Yes, even in the previews the webstorage held up.

Thanks mate!
Image
B
15
S
4
G
3
Posts: 119
Reputation: 3,787

Post » Sun Jun 29, 2014 6:41 pm

Nope, usually for variables/expressions there should never be quotes I think, and awesome glad to hear it's working! :)
"Construct 4 lets YOU make advanced games! (but not play them)" Construct Classic - Examples Kit
B
113
S
39
G
17
Posts: 2,184
Reputation: 19,217

Post » Mon Jun 30, 2014 12:45 am

Well, thanks Jayjay! With webstorage I've made a fully functional multiple save game menu. It was mainly for all the arrays I've used for level completion, gold coin gathering, and power upgrades.

Unfortunately the tokens you collect to buy the upgrades will disappear when you restart your save file since they are global variables. Originally I was using save states, but the save states can mess up other saves which was another part of my frustration. I may have to revamp the game somehow, but I feel better that this issue was resolved.
Image
B
15
S
4
G
3
Posts: 119
Reputation: 3,787

Post » Mon Jun 30, 2014 2:00 am

You can try storing the global variables into the array on save and then when loading set them from array :)
"Construct 4 lets YOU make advanced games! (but not play them)" Construct Classic - Examples Kit
B
113
S
39
G
17
Posts: 2,184
Reputation: 19,217

Post » Mon Jun 30, 2014 2:08 am

Jayjay wrote:You can try storing the global variables into the array on save and then when loading set them from array :)


I didn't know you could do that, but I also found another method that also worked, I used a tutorial from here:
https://www.scirra.com/tutorials/968/ho ... webstorage

I don't know if that's what you're referring to, but It took some figuring out since I'm still a touch programming illiterate when it comes to this stuff, but after a few placements I finally managed to figure it out and now the global variable for my game's tokens are saveable! (As long as the user doesn't oversave the wrong file, haha.)

Thanks for your help mate.
Image
B
15
S
4
G
3
Posts: 119
Reputation: 3,787


Return to How do I....?

Who is online

Users browsing this forum: Colludium, ismailsawan, ketramtu18, mekonbekon and 3 guests