Having two problems with webstorage

0 favourites
  • 8 posts
From the Asset Store
For problem solving, puzzles, bubbles, platforms and other adventures.
  • I'm working on a game with some friends, and I'm having two problems.

    1: I have a planting system (akin to Pokemon's berries system) going on and it remembers each plant just fine, but upon loading a saved file; an extra plantspot appears in the topleft corner.

    2: It seems to remember the values of the player just fine, but anything that's an event or non-player object (even set to global) doesn't seem to get remembered in it's last state, even if it's values are saved to webstorage and remembered. See in the capx, with the small animals and seeds.

    Capx

  • For the first problem, it turns out it has to do with creating instances upon loading but I'm not sure what is the actual problem further in. I figured this out earlier, when creating/destroying plantspot instances was messing with the instance variables.

    As for the second one? I'm not sure...stumped.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That plantspot creating loop:

    For "trees" from 0 to TreeSaved.Width

    should be

    For "trees" from 0 to TreeSaved.Width - 1

    That probably explains the extra plantspot at 0,0.

    2. I haven't looked through all the code (there's a lot) but it looks like you're loading the values from webstorage on the title screen and then setting them to default values on start of layout.

  • I'm getting closer, but haven't quite fixed the first or second.

    1: Plantspot doesn't appear on first load, but on all loads after, it does

    2: Got time system to work upon loading, will do more work.

  • Any more help, please? I really like to figure this out, then I think I would be able to understand webstorage fully.

  • Help, please?

  • 2. I haven't looked through all the code (there's a lot) but it looks like you're loading the values from webstorage on the title screen and then setting them to default values on start of layout.

    I haven't downloaded your code either, but I trust Ramones' judgement on this.

    What he means is that you should make sure in your "On start of layout" to only set the default values once, the very first time you execute your program and not every time the layout starts otherwise you will be under the impression that only default values are saved when they are in fact overwritten.

    I'd suggest you to read my tutorial Asteroid clone in less than 100 events, I explain a great deal about webstorage and it should be just what you need.

  • So, I could check for a placeholder key (like say "SaveFileExists") and set the values if it doesn't exist but with the Trigger once while true condition?

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