What am i doing wrong?

Get help using Construct 2

Post » Sat Sep 20, 2014 2:07 am

I am trying to save the highscore using webstorage I have done this in the past but for some reason the same method is not working I am doing the following:

-On start of layout
Subevent:
- Webstorage- if local key exists - System - High > WebStorage.LocalValue("Score")

-Else - System - Set High to 0

Then:

on population = 0
SubEvent-
- System - Kills >High - Webstorage - Set local key "Score" to Kills


Then on the Highscore event screen I have this:

On start of layout- Set Text to "score"

What am I doing wrong all I get is the word text showing..

Any help appreciated!
B
5
S
2
Posts: 105
Reputation: 837

Post » Sat Sep 20, 2014 2:26 am

Here you go. It's not a bug. I have it working in all my game. Here is a example project File.
You do not have the required permissions to view the files attached to this post.
[b]Andrew Donelson[b]
Nlaak Studios, LLC
https://www.nlaak.com/
[email protected]
B
15
S
3
Posts: 66
Reputation: 1,136

Post » Sat Sep 20, 2014 2:37 am

Thank your for your reply I will check it out now :D
B
5
S
2
Posts: 105
Reputation: 837

Post » Sat Sep 20, 2014 3:02 am

Np
[b]Andrew Donelson[b]
Nlaak Studios, LLC
https://www.nlaak.com/
[email protected]
B
15
S
3
Posts: 66
Reputation: 1,136

Post » Sat Sep 20, 2014 3:18 am

Im still getting the problem, even though Nlaakald's capx helped a bit the problem is still there I only see Text as the result.
B
5
S
2
Posts: 105
Reputation: 837

Post » Sat Sep 20, 2014 4:05 am

maybe you can post your capx
"If you want to move a mountain tomorrow, you should start by lifting stones today."
B
64
S
14
G
2
Posts: 291
Reputation: 6,666

Post » Sat Sep 20, 2014 4:16 am

StrangeyD wrote:Im still getting the problem, even though Nlaakald's capx helped a bit the problem is still there I only see Text as the result.

You're probably having a NaN loaded into number variable.
Anything you store in webstorage is going to be a string, when you load it back, if the localkey supposed to be numerical, you have to convert it using int(webstorage.localvalue("XXX")).
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Sat Sep 20, 2014 2:09 pm

it was (my capx) is a timer that counts and saves. Number to string and back. He's going to have to post his so we can see whats going on.
[b]Andrew Donelson[b]
Nlaak Studios, LLC
https://www.nlaak.com/
[email protected]
B
15
S
3
Posts: 66
Reputation: 1,136

Post » Sun Sep 21, 2014 2:08 am

I am trying what duckface ninja suggested im not sure but think this may be the problem.
B
5
S
2
Posts: 105
Reputation: 837

Post » Sun Sep 21, 2014 2:21 am

StrangeyD wrote:On start of layout- Set Text to "score"


Are you using quotation marks in that event ? take that off if so
Also try Every tick - set text to score (Variable)
B
6
S
2
Posts: 151
Reputation: 1,366

Next

Return to How do I....?

Who is online

Users browsing this forum: ametueraspirant, dand, mickclarke and 27 guests