How do I make a variable which will be the same when I load?

0 favourites
  • 5 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I need to make a variable that would be the same, even when I load a Save data.

  • I'm not sure about your question

    You can make global variables constant (checkbox when you create a variable) - here the variable can't be changed.

    But if you use local storage you can decide what happens.

    Like a condition when localStorage loaded | set variableX to 1

    If you use the standard system save and load (not recommended) you still can make another action after the load - like set value of variableX

  • UltimateArceus3 - In this situation you need the local storage to make you a backup of the value of the variable so that when you load a saved data, your variable can be updated by the backup from the local storage since local storage's aren't affected by saved data's.

    Example;

    You have a variable named "Health"

    And a local storage key named "Health_Backup"

    *System->On Load Complete

    ----->Get item --> Key "Health_Backup"

    *LocalStorage->On Item Get->Key "Health_Backup"

    ------> System->Set Global Variable Value-->Variable 1 to LocalStorage.ItemValue

    ------"That Should do it"------

  • I'm not sure about your question

    You can make global variables constant (checkbox when you create a variable) - here the variable can't be changed.

    But if you use local storage you can decide what happens.

    Like a condition when localStorage loaded | set variableX to 1

    If you use the standard system save and load (not recommended) you still can make another action after the load - like set value of variableX

    Excuse me, but since you touched the subject, why shouldn't we use the native saving scheme?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • cenowador

    The standard save/load has a lot of limitations.

    Like what happens when you make an update of your game with new stuff in it (like new variables).

    When I first played with save/load - sometimes my game broke

    Like sound was playing even when before it was turned off and saved in this state. So when I tried to turn off the sound it played twice.

    With local storage you are in total control - so I prefer it.

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