NaN

Bugs will be moved here once resolved.

Post » Tue Aug 14, 2012 4:00 pm

Hello!

I have problems with saving. In the text fields show me the NaN.
If I remove the loading (WebStorage object) - all is well. But! When I tested the game on Wi-Fi on iPad all worked correctly. When tested through a browser - NaN.

Then I just cut out the loading data (WebStorage) and put into place, in the browser everything was working, but iPad - NaN.

I saved the project and uploaded it to the site. On the PC and mobile devices - NaN.
B
53
S
7
G
6
Posts: 51
Reputation: 7,136

Post » Tue Aug 14, 2012 4:15 pm

I don't know what events you're using which are resulting in NaN. Can you share a .capx for each case?
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Tue Aug 14, 2012 5:41 pm

nananananan Batman! :)

Also, NaN occurs when you try to add strings to numbers, you probably have two variables - one is text one is number and you add them using & or +

Cast them properly - if you use & make a string(variable); if you use + make a int(variable) or float(variable)

and as Ashley said, without events we probably won't be able to help you more here :(
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Tue Aug 14, 2012 5:41 pm

Are you dividing by 0?
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Wed Aug 15, 2012 3:51 am

@ranma @sqiddster
Thanks for your reply.

I made a simple example. When I test in the preview mode - all excellent.
But when the game load on the server - NaN

What am I doing wrong?

Tnanks

(screenshot)
https://dl.dropbox.com/u/38677931/screen.png
B
53
S
7
G
6
Posts: 51
Reputation: 7,136

Post » Wed Aug 15, 2012 9:28 am

event 2: set score to int(WebStorage....)

webstorage stores all values as string, so if you get a value from it to a number type local variable, you should cast it to int.
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Wed Aug 15, 2012 9:47 am

@ranma

Can you make an example? I will be very grateful to you.
I do not understand :(
B
53
S
7
G
6
Posts: 51
Reputation: 7,136

Post » Wed Aug 15, 2012 10:14 am

B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Wed Aug 15, 2012 10:16 am

also @Ashley maybe you should make this kind of carsting automatic? if a global / local variable is of type number, cast every string to float automatically? or check if you are trying to set it to string in an event?
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Wed Aug 15, 2012 10:31 am

@ranma

Thank you so much!
B
53
S
7
G
6
Posts: 51
Reputation: 7,136

Next

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest