Saving object states and INI files:

For questions about using Classic.

Post » Tue Jul 14, 2009 11:17 am

I need to save the states of an arbitrary number of objects in the same family between layouts (I do not wish to make all the objects global). From what I can tell, an INI object is best suited to this purpose, is this correct? If so what is correct way to store and retrieve the data from the INI file?
For each object of type family
->ini write (data type) [group name] [item name] value
For each of that objects private variables?
This seems to only be writing one object of each family to the file.

How would I restore the data to the proper objects when returning to a layout (I am using system create by name)?
If there is a better way, please let me know.
Some quick examples would be very helpful I did read the wiki but it did not go into any depth.
Thank you.
Posts: 9
Reputation: 843

Post » Tue Jul 14, 2009 5:05 pm

I think the save/load or quicksave/quickload actions would be better suited to saving your game!
Scirra Founder
Posts: 22,829
Reputation: 176,674

Post » Tue Jul 14, 2009 6:49 pm

Hello Ashley, very impressive engine you have here.
My understanding is that full saves/loads and quick saves and quick loads replace the existing game state entirely (is this the case?). I need to have some global variables preserved (at a minimum).

The general flow would be
1. objects from layout one are saved (move to layout 2)
2. an arbitrary number of the these objects are spawned in layout 2
3. they do something,
4. the status of the objects in layout 2 are saved and
5. return turn to layout one and repopulate the level from the saved data

Is you recommendation still the same in light of this additional information? Sorry, it was very late when I posted or would have included more info in the initial post.

Thank you!
Posts: 9
Reputation: 843

Post » Tue Jul 14, 2009 9:01 pm

If your writing to the same group and the same item it will always only save one group and one Item. You need to use and expression in place of the group name and leave the Item the same. I suggest using object.uid for the group name. and name the items something intelligible. if you want to save PVs you would do better using a hastable to hold the variables you want to save.
Posts: 632
Reputation: 2,829

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests