simplest local storage as possible ?

0 favourites
  • 14 posts
From the Asset Store
Basic Plugins for Firebase Authentication, Realtime-Database, Firestore, Cloud Storage
  • hi guys, i was wondering what is the cleanes, and shortest way to save a global variable ( i saw many examples, but feel that i do not need all the codes)... i need this: press + key = set value 1 , press - key = set value 0 and each value is always saved as local strage...

  • Local Storage -> Set item "MyValue" to myGlobalVar

    That's it.

  • hi sorry, i am new in this saving stuff..it did no really work...

    I have this.. if i press + add 1 to global ...if i press - subtract 1 from global... if I close and reopen the game it should remember it... could you maybe post a image of the code ? thanks

  • | Global number Variable1? = 0

    --------------------

    The following is so that when you close, your value is loaded

    --------------------

    + System: On start of layout

    -> LocalStorage: Check item "MyVar" exists

    + LocalStorage: On item "MyVar" missing

    -> LocalStorage: Set item "MyVar" to Variable1

    + LocalStorage: On item "MyVar" exists

    -> LocalStorage: Get item "MyVar"

    + LocalStorage: On item "MyVar" get

    -> System: Set Variable1 to LocalStorage.ItemValue

    --------------------

    The following is to save the value when it is modified

    --------------------

    + Keyboard: On Numpad add pressed

    -> System: Add 1 to Variable1

    -> LocalStorage: Set item "MyVar" to Variable1

    + Keyboard: On Numpad subtract pressed

    -> System: Subtract 1 from Variable1

    -> LocalStorage: Set item "MyVar" to Variable1

  • thanks a lot... so that is the MINIMUM of code ?

    can U give a look to this:

    it seems to work..but i don't know if I made mistakes...it is a very short code

    https://lookaside.fbsbx.com/file/save%2 ... 2B8wLcd4EM

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You only asked how to save a value, you didn't ask how to load it <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    This is the bare minimum code:

    Also, have you tried googling? There are plenty of tutorials with good examples of using the local storage:

    https://www.scirra.com/tutorials/all

    In your capx you are not saving high score in Local Storage! You are saving and loading the entire game.

  • thank U so much 4 your help

    stupid question... what do u mean with the entire game..is it not related only to the variable ?

    is it also ok...or is it totaly wron to make it like that ?

    thanks 4 the help

  • thank U so much 4 your help

    stupid question... what do u mean with the entire game..is it not related only to the variable ?

    is it also ok...or is it totaly wron to make it like that ?

    /quote]

    As dop2000 indicates, you are using 'Save Game'

    https://www.scirra.com/tutorials/526/how-to-make-savegames

    This would save the current status of everything, not just a variable/options.

  • mariogamer

    I'm confused.. How did you make this awesome game and yet asking these very basic questions?

  • ... the problem is that I suffer strong dyslexia and unfortunatelly also discalculy... this means that what 4 you guys is so simple to proccess...sometimes for me is such a pain

  • Kudos to you! I'm terrible with graphics and visual effects..

  • thanks 4 ur help

  • mariogamer

    There are no stupid questions, only stupid answers.

    You are doing great, keep up the good work. Believe in what you are doing and be determined to finish what you started.

    You are on your way to success!

  • thanks

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