How do I use the "int" behavior with WebStorage?

Get help using Construct 2

Post » Mon Mar 23, 2015 3:13 am

I'm not quite sure how to use the "int" behavior in WebStorage. The money only goes up once when I don't but I tried it and it doesn't work. Does this look right?

int(WebStorage.LocalValue("TotalMoney")) > 0: Set Money to int(WebStorage.LocalValue("TotalMoney"))


Money not equal to int(WebStorage.LocalValue("TotalMoney")): Set Local Key "Total Money" to Money

Thanks for any help!
B
12
S
3
Posts: 129
Reputation: 1,131

Post » Mon Mar 23, 2015 9:34 am

I am not sure what you want to do, but I see there is a space added in "Total Money", while your other local value use "TotalMoney"
It's time for me to return the favor :)
B
32
S
9
G
9
Posts: 132
Reputation: 5,370

Post » Mon Mar 23, 2015 11:06 pm

That was just a typo. Someone told me that when comparing two values, convert it into an int() or float() in first.

I meant when the money system only goes up once, i play one game, then it adds the coins, but then I do it again and the coins just stay the same. It's definetly a problem with the WebStorage because it was working fine before then.
B
12
S
3
Posts: 129
Reputation: 1,131

Post » Tue Mar 24, 2015 11:45 am

I am still confused with what you want. I guess you only want to update the web value when Money is bigger. Also set Money to the webvalue only at the start. Try these two method
1) add/change a couple of conditions
On start of Layout+int(WebStorage.LocalValue("TotalMoney")) > 0: Set Money to int(WebStorage.LocalValue("TotalMoney"))
Money bigger than int(WebStorage.LocalValue("TotalMoney")): Set Local Key "Total Money" to Money

2) Try to switch the order like this and put them at the bottom of the event sheet.
Money not equal to int(WebStorage.LocalValue("TotalMoney")): Set Local Key "Total Money" to Money
int(WebStorage.LocalValue("TotalMoney")) > 0: Set Money to int(WebStorage.LocalValue("TotalMoney"))
It's time for me to return the favor :)
B
32
S
9
G
9
Posts: 132
Reputation: 5,370

Post » Wed Mar 25, 2015 12:40 am

I tried that too but it still doesn't work. This was my post from before that i was talking about: scirra.com/forum/viewtopic.php?f=147&t=127076 What I want is the Money value to go up every time on play because it only goes up after the first time right now.
B
12
S
3
Posts: 129
Reputation: 1,131

Post » Thu Mar 26, 2015 2:09 am

bump.
B
12
S
3
Posts: 129
Reputation: 1,131

Post » Thu Mar 26, 2015 5:22 pm

Sorry for the late reply, I've got busy lately.
Without further ado, here we go!

I think I see the problem. You might be overwriting the webstorage value with the last Money value instead of adding to it.

Try the following.
On start of Layout : Set Money to int(WebStorage.LocalValue("TotalMoney"))
On winning the game : -Add 250 to Money
-Set Local Key "TotalMoney" to Money
It's time for me to return the favor :)
B
32
S
9
G
9
Posts: 132
Reputation: 5,370

Post » Thu Mar 26, 2015 10:30 pm

That worked, thank you!
B
12
S
3
Posts: 129
Reputation: 1,131


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests