Array layout scope

Discussion and feedback on Construct 2

Post » Mon Aug 22, 2011 3:56 pm

Hey,
I've been occuring a strange behaviour in r50.
I have two layouts in my app.
I tried to fill an array with values from a layout, and use those values in the other layout.
From the second layer, it seemed the array was empty (only returning 0) whereas from the first layout, it was obvious the array was filled. (the array contained different values).

I had created/added my array to the first layout.
I've tried a bunch of stuff around, questionning my code, etc...
In the end, I resolved to put the filling code in the same layout/eventsheet that the code which gets infos from the array. And there, either filling and getting values did not work.

Last solution, adding a new array to my second layout (containing the fill and get code) and all work as intended.

So it seems the array only applies to the layout it is added to.
There's no "global" option for the arrays and no way to tell which is their layout of of belonging.

Have I missed something, is it intended behavior ?
Is this already had been spotted and resolved in upcoming r51 ?
I was kind of hoping r51 would be out when I'd wake up today (^^).

Anyway, I thought I would post it and wait for Ash explanation.
On another note, I have been intensivly using C2 during this week end for the Ludum Dare (I'm still on for the "Jam" entry) and I must say that it has been gladely stable. I've only occured a few bugs (already known and that I should have avoided) and in the whole, it it a nicely reliable tool.

I love the fact that globals var now are just "name_of_var" no more tedious Global["my_var"] or whatever method of CC.
It is just a blast.Kyatric2011-08-22 15:57:44
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Mon Aug 22, 2011 3:59 pm

Right now there's no Global feature - so all objects (including Arrays, but excluding 'single globals' like Keyboard and Mouse) are destroyed at the end of the layout. I haven't got Global for r51 I'm afraid but I'll try get it done for r52!Ashley2011-08-22 16:00:30
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Mon Aug 22, 2011 4:35 pm

Ok, then that makes perfect sense.
I only wished I hadn't had to learn it "the hard way"

Keep up the good work anyway.Kyatric2011-08-22 16:36:13
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Sun May 06, 2012 7:41 am

Is this still in progress? I would love to be able to transport my inventory array between layouts.


I am thinking I might be able to get away with reconstructing the array between maps by using a FOR EACH with a "Pipe" delimiter...

Something similar to
ArrayPass0 = ArrayPass0 & "|" & MenuArray.At(MenuArray.CurX,MenuArray.CurY,MenuArray.CurZ)

Then for each on paramater of xyz for

tokenat(arraypass0, loopindex+1,"|")


...on the other map

No luck yet.. but thats my ideawGillis2012-05-06 08:38:38
Image
B
35
S
13
G
9
Posts: 142
Reputation: 7,340

Post » Sun May 06, 2012 7:55 am

@Gillis: This is a very old thread.
Arrays now have the global property.

Be sure to create the original instance on the first layout you will visit, set the "Global" property to yes and from there your array is accessible from any layout.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Sun May 06, 2012 8:39 am

OK. Somehow it bogs the cpu down when I go global. Let me double check a few things. r87
Image
B
35
S
13
G
9
Posts: 142
Reputation: 7,340


Return to Construct 2 General

Who is online

Users browsing this forum: hollowthreat, Solomon, zenox98 and 8 guests