Saving and Loading Private Variables

This forum is currently in read-only mode.
From the Asset Store
Color Variable
$4.50 USD
10% off
Easily store, modify, read and manipulate colors with Color Variables!
  • Hey Guys,

    First off, let me tell you guys that you have done a great job with this project. Construct is a wonderful tool to use.

    I have a couple of questions. Say I have a 4 x 4 grid of simple square objects that are all instances of the same sprite. When I click on one, it changes a private variable in that instance. How would I go about saving these variable changes using a 4 x 4 array and then load it the next time the layout is started?

    Also, is there any limit in the number of arrays you can have in a single layout/game?

  • There's no limit on the number of arrays or objects, unless you run out of memory (which is fairly unlikely).

    You could try the system object's save and load or quicksave and quickload actions. They'll save the entire game state, including all private variables. Alternatively you could try an object like INI and save the ones you need to disk.

  • Thanks for the quick response! I was just curious. In MMF I was able to spread a number into one of the object's variables to give them unique ID's. Then I used fastloops and the mod function to record the variables of each instance to an array and then load them at a later time, but that method isn't possible in Construct.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can just use 'for each object' instead to save stuff

  • Yeah, the spread values stuff is basically a long way of doing for-each (a system condition). You might be interested in for-each-ordered too, where you can change the order in which the objects are looped. A single 'for each' condition is basically the same as the 'On loop "i" / pick object whose value A = loopindex("i") event, without the spread values/variables/separate event cruft.

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