how can i use LocalStorage like WebStorage to do compare two values

0 favourites
  • 6 posts
From the Asset Store
This is a Dungeon Master tool & the 1st of 12 Combat Engines from the Building Combat Engines for Browser Games workshop
  • I would like do a screen about levels, then i compare the currentLevel and change my frame

  • Problem is, you cannot use LocalStorage 'like' WebStorage, unfortunately.

    You're using the right expression, LocalStorage.itemValue

    but, to get that itemValue in that expression, you'll first need to use a separate action:

    LocalStorage: Get item: "currentLevel"

    Then use a separate event of LocalStorage: On Get Event ("currentLevel") and then use Compare two values as its sub-condition. Then LocalStorage.itemValue will contain the value of "currentLevel".

    I know, I miss webStorage too.

  • maybe im using it wrong, can u help me?

  • Yes. You're using it wrong. I already told you how to use it.

    You posted the same screenshot again.

    This is what you need to do:

    Action:

    LocalStorage: Get Item "currentLevel"

    Condition:

    LocalStorage: On Item Get: "currentLevel"

    Compare two values: int(LocalStorage.itemValue)

  • I have 10 levels in total, I'm not getting him to keep the levels open when I leave and return to the game, for example, if I play 3 stages, when I close and open he goes back to stage 1 and should be up to the stage 3 open.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You're not updating 'level_atual' variable, it's always 1.

    Besides, you don't need that variable.

    Just use these conditions instead:

    levelselect.level <= LocalStorage.itemValue then Set Animation frame to 1

    Else: --> Set Animation frame to 0

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