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,122
Reputation: 11,282

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
22
G
259
Posts: 3,794
Reputation: 143,704

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,122
Reputation: 11,282


Return to How do I....?

Who is online

Users browsing this forum: VValt and 29 guests