How do I save object information between layouts?

Get help using Construct 2

Post » Tue Oct 25, 2016 9:53 am

Hi, I am doing a room generator with all its connections. I want to do it in 3D space, so I can have X rooms width, Y rooms height and Z depth, and each room can have 6 possible connections with its neighbour rooms. I made a object called "room" that can store connections information with instance variables. I create X x Y x Z rooms and I save their UIDs in an array, then I run my algorythm and it works fine. Ok, but when I want to start playing, each room is a different layout, so when I load the first layout or whatever, all my "room" instances with its information are lost. Is there anyway to make an array to save object instances instead of only numbers an text? I dont want to use infinite arrays to store all the information and I can't change the layout per room system.

So, Can I save my object instances between layouts? I know there is the persistent behaviour, but I think it wont work like I want, because it saves it for a specific layout. I want to have my X x Y x Z array with my objects UIDs and access that objects in all layouts.

Thanks in advance ^^
Last edited by ezrubiera on Wed Oct 26, 2016 10:05 am, edited 1 time in total.
B
6
S
2
Posts: 61
Reputation: 1,099

Post » Tue Oct 25, 2016 10:37 am

You can't do it like this, probably use instance variables on the actual object. I'm not 100% sure how you are using the UIDs but when the objects are created in the layout the UID is set unique for that one specific object, when you create them in the next layout they will always have different UIDs. And to also answer the question in the title, the UIDs are saved between layouts but you are creating new objects with new UIDs.
B
46
S
16
G
74
Posts: 2,088
Reputation: 44,185

Post » Wed Oct 26, 2016 9:54 am

Yes, that is the main problem, I store the UIDs but in the next layout they are useless. So how can I save the information of that objects between layouts? If I generate a 2 dimension array of rooms, I can store the information in the 3rd dimension of the array for each room, but if I have a 3 dimension array of rooms, I dont know how to store its information. I can use a lot of arrays for each variable but is kinda messy. So I need a workaround to solve this: store the information (intance variables) for X x Y x Z rooms. D:
B
6
S
2
Posts: 61
Reputation: 1,099

Post » Wed Oct 26, 2016 12:40 pm

You can turn your Rooms into global objects, you do this in the properties panel, top left corner. Then they will be available in all your layouts.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838

Post » Wed Oct 26, 2016 1:50 pm

nimos100 wrote:You can turn your Rooms into global objects, you do this in the properties panel, top left corner. Then they will be available in all your layouts.



Oh! I have to try that. I guess the UIDs are saved between the layouts, so I can access every object with the same UID through the rooms. Thank you, I will reply when I try it. Thanks in advance ^^
B
6
S
2
Posts: 61
Reputation: 1,099

Post » Wed Oct 26, 2016 3:28 pm

ezrubiera wrote:
nimos100 wrote:You can turn your Rooms into global objects, you do this in the properties panel, top left corner. Then they will be available in all your layouts.



Oh! I have to try that. I guess the UIDs are saved between the layouts, so I can access every object with the same UID through the rooms. Thank you, I will reply when I try it. Thanks in advance ^^


Yeah its the same object from once its created with all settings etc.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838

Post » Wed Oct 26, 2016 9:58 pm

nimos100 wrote:
ezrubiera wrote:
nimos100 wrote:You can turn your Rooms into global objects, you do this in the properties panel, top left corner. Then they will be available in all your layouts.



Oh! I have to try that. I guess the UIDs are saved between the layouts, so I can access every object with the same UID through the rooms. Thank you, I will reply when I try it. Thanks in advance ^^


Yeah its the same object from once its created with all settings etc.


Mate, it worked perfectly! thanks a lot :D :D :D
B
6
S
2
Posts: 61
Reputation: 1,099


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 5 guests