WEBSTORAGE ERROR!!!

Get help using Construct 2

Post » Sat Aug 23, 2014 12:46 pm

Hey Guys,

I was using webstorage to save the number of coins a player has. moreover, after the game finishes, the number of coins he collected added to the webstorage. But, when i exported via XDK to android, it shows NaN.
What does that mean?
How do i get it to work? :oops:

I would like a quick reply as i need to submit the game soon.

Thanks,
Ashwin Alaparthi
B
15
S
3
G
1
Posts: 111
Reputation: 1,664

Post » Sat Aug 23, 2014 12:48 pm

NaN is "Not a number" Maybe try int() or float() functions onto the value, as it retrieves webstorage values as Strings i think, so you need to convert it to a number before any numeric usages
B
32
S
7
G
2
Posts: 317
Reputation: 2,851

Post » Sat Aug 23, 2014 1:44 pm

Any help on how I can convert it?
B
15
S
3
G
1
Posts: 111
Reputation: 1,664

Post » Sat Aug 23, 2014 2:43 pm

IndieKiwi wrote:Maybe try int() or float() functions
B
47
S
14
G
7
Posts: 603
Reputation: 8,141

Post » Sat Aug 23, 2014 2:49 pm

Any new install will report NaN if nothing was stored initially. Are you checking if the key exists before reading it?
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, valefor and 22 guests