Is it just me or am i not able to save an Instance Variable?

  • Hi everyone,

    It seems like im not able to load up or save my instance variable that ive chosen to represent an Unlocked/Locked state.

    All of my Globals load up and save just fine.

    Right now when the player touches the confirm button inside the store it saves using this code.

    Webstorage-->Set Local Key"GunUnlock" To TurretGun_BttnFam.UnlockedGun

    When i load the game from the first layout i use this code.

    Set UnlockedGun To int(WebStorage.LocalValue("GunUnlock"))

    Im not understanding why it will not save my chosen variable,am i doing something wrong?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You are saving UnlockedGun to one webstorage key ("PowerupUnlock") and trying to load it from different key ("GunUnlock")

    Or do I miss something in your explanation?

  • shinkan that was my mistake,I fixed it inside the post,Its not that way inside my capX and never was.I just wrote to fast in this post.

    I am still having this issue.It will not save the state of the instance variable.

  • hard to say without looking at your file. It works fine on my end.

  • What does the webstorage say about the saved value? (Look inside the browser itself)

  • Aphrodite What do you mean? could you clarify that statement?

    shinkan do you mind if i PM it to you? I have it set up the same way as i posted. Im just about finished with my project and its too far gone to post out in the public.

  • sure

  • shinkan its coming your way right now,Thank you for checking this out.

  • Don't use WebStorage.Set. Instead use WebStorage.Add

    Same with dictionary. And here is why,

    1. Until you Add a value to Web/Dict there is no variable to set with. So Setting won't work.

    2. Add will always add a variable.

    3. Add will overwrite a variable that already exists. So your never actually increasing the number of vars stored.

    So unless there is better memory performance with using Set. Just use Add all the time.

    I had the same problem over a year ago. Then I read the manual and was informed this piece of information.

  • Never mind. I'm being a doorknob. WebStorage s not the same. I guess I overlooked the value since I only use WebStorage to save bulk data in Dictionaries.ToJson.

    RookieDev are you maybe clearing your WebStorage for development testing?

  • jayderyu

    There was a different issue with his project. He had 13 instances of same object with some variables. And while saving to webstorage he did not specify what he want to save.

    Webstorage-->Set Local Key"GunUnlock" To TurretGun_BttnFam.UnlockedGun [/code:yup8lgsg]
    1 instance of [b]TurretGun_BttnFam[/b] had [i]UnlockedGun[/i] variable set to [b]1[/b]  but other 12 instances had [i]UnlockedGun[/i] variable set to [b]0[/b]
    
    So this one event was "confused"  what to save.
  • Aphrodite What do you mean? could you clarify that statement?

    shinkan do you mind if i PM it to you? I have it set up the same way as i posted. Im just about finished with my project and its too far gone to post out in the public.

    For instance, open the chrome console to check the values stored inside the webstorage, so you know if it is saved as it should or not.

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