Values greater than 9 causing weird issue

Get help using Construct 2

Post » Thu Jun 02, 2016 12:38 pm

I'm giving layouts static numbers as names (1,2,3,etc) and I am testing these numbers for LocalStorage events, to figure out which level is unlocked. Strange thing is, if the layout name is greater than 9, it doesn't seem to be saving the value properly LocalStorage, since there's a condition to only save the item if the variable is greater than the current layouts name (when returned as a number rather than a string). Does LocalStorage think of 10 as being somehow below 2, or does LocalStorage only keep numbers on single digit?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Thu Jun 02, 2016 12:43 pm

Makes sure to convert the values back to numbers. At the moment it is comparing "2" to "10" as a string: "2" < "10".
ImageImageImage
B
71
S
21
G
220
Posts: 3,646
Reputation: 123,721

Post » Thu Jun 02, 2016 12:44 pm

blackhornet wrote:Makes sure to convert the values back to numbers. At the moment it is comparing "2" to "10" as a string: "2" < "10".

Ahh, works now I changed "Value /> LayoutName" to "Value /> int(LayoutName)" I must have been getting on by with luck until now! Thanks!
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253


Return to How do I....?

Who is online

Users browsing this forum: mrkaio, Zav and 3 guests