Webstorage / Instance Variable

0 favourites
  • 4 posts
From the Asset Store
Color Variable
$4.50 USD
10% off
Easily store, modify, read and manipulate colors with Color Variables!
  • 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.

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

    int(WebStorage.LocalValue(LayoutName))
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ahh, but only for instance variables?

    Thanks GeometriX

    I was adding the int expression a lot earlier!

  • Nope, it applies to all number variables.

    My pleasure :)

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