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

0 favourites
  • 8 posts
  • 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!

  • 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"

  • 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.

  • 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"))

  • 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.

  • bump.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • That worked, thank you!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)