array values not being set?

Get help using Construct 2

Post » Sat Jun 23, 2012 2:08 pm

Hi,

This is probably a very silly problem, but a problem nevertheless. For some reason after setting the value at (1,1,1) in my array, the .at(1,1,1) returns zero

Please see the tiny capx that i was trying to get to work...

Since there's no way of console debugging (two plugins i found didn't work), i couldn't come up with anything better to make it work. Any help much appreciated
B
4
Posts: 8
Reputation: 666

Post » Sat Jun 23, 2012 2:11 pm

I cant check the .capx right now but Im assuming you didnt change the default size of the array, which is zero based, so try 1,1,0 or 0,0,0 and see if that fixes it! Right now you are writing to a z index which may not exist.Tokinsom2012-06-23 14:13:27
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Sat Jun 23, 2012 2:34 pm

i thought i triple checked everything, here's a screenshot of the event sheet in question

B
4
Posts: 8
Reputation: 666

Post » Sat Jun 23, 2012 2:53 pm

When retrieving a numerical value for a string you may have to add int(). Try int(worldarray.at(1,1,1)) instead :)Tokinsom2012-06-23 14:56:08
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Sat Jun 23, 2012 2:56 pm

This is a known problem in Construct 2: you inserted the worldArray object to a layout, deleted that layout, and now you can't use the object.

When you insert an array an invisible instance is also added to the current layout. If you delete that layout the object then has no instances, so you can't store any data in it, but it still appears in events. You can tell this has happened because if you select worldArray in the project bar, it should have width, height and depth properties, but those properties do not appear. Your 'On array created' event will also not be running, because there is no array that gets created.

I'm afraid for now all you can do is replace the object, or tweak the project XML to add the array to another layout. We're aware of this problem - I'll see if I can get something in the next build to make this clearer and easier to work with.Ashley2012-06-23 14:56:50
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Sat Jun 23, 2012 3:10 pm

That'd be right, as int() didn't work, but replacing the object means slaughtering all events related to my array. Ah. I'll just wait for a new build and hope it's dealt with. It's not a huge deal to replug it all again but I'd love to make sure I don't accidentally delete a layout that has an invisible array in the future :) Thanks!
B
4
Posts: 8
Reputation: 666


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 4 guests