How do I save/load Instance variables?

0 favourites
  • 8 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • How can I save/load an object's Instance Variable?

    For example I want to create treasures for a game, the event needs an Instance Variable to be opened, so that I can replicate more treasures in the game. So how can I save Instance Variable of those objects? Is there a way to save Families? If I understand LocalStorage correctly I can't use it, it's only for Global Variables.

  • If you mean saving in the sense when the user quits the game and reopens it then system save/load is good enough or look up how to make savegames in the manual. If you mean saving in the sense of storing variables during the game session and going between layouts then I would use global variables.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey there, thanks for the reply. :)

    I need to save and load Instance Variable of a Sprite. With LocalStorage it doesn't seem possible. Also, if it were possible to save entire groups via "Families", that would be best.

  • I think you are looking for save and load game under system. I can't think of a reason to save an instance variable on specific instance and it doesn't seem possible.

  • Hey there, thanks for the reply. :)

    I need to save and load Instance Variable of a Sprite. With LocalStorage it doesn't seem possible. Also, if it were possible to save entire groups via "Families", that would be best.

    You can save any data to localstorage - I write all the variables I want to save to a dictionary then save/load that in one operation. So maybe you could loop through all your sprites, write their UID & instance variables to a dictionary, the save that?

  • you could save them to an array. then download it as a json file.

    ok i havent actually downloaded one yet, just loaded them.

    but have a free json file named "saved"

    go array-dowload to json - type "saved"

    i hope that works... my plan is revolving around it

    to load the json file youll need AJAX object.

    start of layout-Ajax request "saved"

    Ajax on "saved" completed- Array-load json string Ajax last data

    Ajax on "saved" complete- Array load from json string "Saved"

    that will put the saved data in the array. then just set variables to the array data where you saved them.

    i hope that helps, im expecting others to come in and correct me... but, that helps me too

  • I tried saving variable instance of an object, but when I then load the game it applies it to all objects of the same type.

    I would need to create multiple Caskets (rpg style) from the same object but keep the variable instance independently. 😅

    Also saving each variable global or not is very time consuming and really requires so many event lines, I was hoping for something more quick also.

  • I gave you the quick option, it's a save game using system save/load.

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