Webstorage / Instance Variable

Get help using Construct 2

Post » Sat Jun 08, 2013 8:59 pm

Hey there, I'm basing an objects frame number by an instance variable which I'm trying to input using webstorage.

I can do this using a global variable with:
WebStorage.LocalValue(LayoutName)

However, if I try to do this using the instance variable, I get the following error:

"You cannot set a string to the number variable - Use int() or float() around the expression to convert"

I try this, and it tells me that it requires a string, and not an integer.

Can someone tell me how to get around this, or why it isn't working? Is it a bug? The data that is stored in the webstorage is a number (ranging from 1-5) so I have no idea why it would be so different.

HELP!!! I am sooo close to finishing my game! 523 events and counting.

@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » Sat Jun 08, 2013 9:33 pm

WebStorage converts everything you put into it to a string, so to put stored values back into a numerical variable, you have to use the following format: [code]int(WebStorage.LocalValue(LayoutName))[/code]
B
57
S
15
G
11
Posts: 912
Reputation: 12,596

Post » Sat Jun 08, 2013 9:48 pm

Ahh, but only for instance variables?

Thanks @GeometriX

I was adding the int expression a lot earlier!
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » Sat Jun 08, 2013 9:52 pm

Nope, it applies to all number variables.

My pleasure :)
B
57
S
15
G
11
Posts: 912
Reputation: 12,596


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests