..use webstore specifically

Get help using Construct 2

Post » Wed Jan 02, 2013 4:28 am

Hi there everyone,

I found this tutorial http://www.scirra.com/tutorials/266/webstorage-how-to-save-ingame-information which shows the process is pretty simple, but it still assumes I know something apparently I don't..

the tutorial shows the command and such, but there is a gap. I'm not sure where this should go.

my intention is to track when something has been done like "first time played" as a true/false condition for future visits.

my assumption is that I add a webstorage object.. i then go into the event page and do a tough event when touching the start button.. i would want to pass a value at that time.

however i don't see a "set local key" option in the system page. then each time the game is loaded i'd want to immediately check the webstorage data to see if its true that the player has been here before.

Thanks!
Caleb

B
51
S
7
G
1
Posts: 869
Reputation: 5,943

Post » Wed Jan 02, 2013 6:22 am

on the first default page

On Layout start
-sub condition: WB.keyexists("played")
->actions: initilize fist info
-> WS.set local value
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Wed Jan 02, 2013 6:54 am

I posted this when helping someone else out, but I think it may help here also..

https://dl.dropbox.com/u/666574/webstorage%20jump%20to%20level.capx
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Wed Jan 02, 2013 7:59 pm

@procrastinator and @jayderyu thanks for that examples! very nice. but because what i'm doing isn't exactly the same i'm having trouble lining the two projects up..

in your example "LevelReached" this is the key right? is this never declared anywhere in the project other than at that moment?

i try to follow your example as close as possible, but it still doesn't seem to retrieve the data..

here is a link the the file so far.. https://www.dropbox.com/s/y5169lh4ymoypqs/save%20values%20trouble.capx

I have a text field in the first stage that shows 0 or 1 to help me know what the value is for "PlayedBeforeVar"

probably missing one tiny thing, but for the life of me i can't see what is wrong.

Thanks!
Caleb
B
51
S
7
G
1
Posts: 869
Reputation: 5,943

Post » Wed Jan 02, 2013 8:38 pm

At first glance, you don't have it loading from the local storage on the first layout.

Insert at the top -
+ If PlayedBeforeWebStorage.Local Key "PlayedBefore" exists (THE EVENT)
- PlayedBeforeVar = PlayedBeforeWebStorage.LocalKey("PlayedBefore") (THE ACTION)

Seems to work for me.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Wed Jan 02, 2013 8:49 pm

Put the check if the key exists as sub event of a "On start of layout".

Also you should "gather" your action sin a single "Every tick" event, it's better for vision and allows you to "free" events if you're using the free version.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Wed Jan 02, 2013 11:07 pm

It's a battle of two , Procrastinator Starts by a shot on the head ! Part12studio gets a revenge , and procrastinator finishes him ! What a battle !
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Thu Jan 03, 2013 12:09 am

Kyatric is correct, you need to group events. I couldn't figure out why I found it hard to follow, but now I know why.

part12studios, also, in your load layout, when the reset button is clicked, you should add...

PlayedBeforeWebStorage set local key "PlayedBefore" to 0

whiteclaws, haha that made me laugh ;p but the battle isn't over yet! Not until part12studios understands and implements and is successful! ;)
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Thu Jan 03, 2013 7:56 pm

Ok we're going to get this thanks you your great help!

So starting with your reply yesterday @procrastinator. you mentioned to insert some stuff. how do i insert? I know i can drag added events from the bottom up top, but it seems to merge them with whatever they sit next too. Maybe this doesn't matter but it doesn't make sense that the two would be fused.. seems like it would matter if they are connected.

I'm going to tackle this more tonight when i have some quiet time as this is taking some serious concentration to wrap my head around what is happening when..

you all rock for helping me through this! :)
B
51
S
7
G
1
Posts: 869
Reputation: 5,943

Post » Thu Jan 03, 2013 9:22 pm

No worries. Glad you're getting there.

Here's a fixed version of your capx. I've commented new additions.

https://dl.dropbox.com/u/666574/save%20values%20trouble.capx

Also, can't remember which layout it was - in game, or load - you had the Goto Layout before your code to reset the PlayedBeforeVar, so the reset was never going to work because it would jump to the new layout first.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Next

Return to How do I....?

Who is online

Users browsing this forum: DiabloOvermind, emoticon, odiusfly, Yahoo [Bot] and 20 guests