UID from created object? And Array Issue [SOLVED]

Get help using Construct 2

Post » Thu Sep 15, 2011 7:18 pm

How the I get the UID of an object that was placed at runtime using the Create Object command?

EDIT: Also, I have the following Command setup:

*Keyboard: A is down
-Array: Set Size to (Array.Width+1,0,0)
*System: Every tick
-Text: Set text to (Array.Width)

But when I press A the size of the array never increases it just remains at zero. I even tried adding on the start of a layout to change the array size to (2,0,0) and the text still says that the array width is 0.kabuto2022011-09-18 15:14:09
B
5
S
2
G
3
Posts: 36
Reputation: 1,622

Post » Fri Sep 16, 2011 12:09 am

I'm not sure what you mean. The .UID expression returns the UID of the currently picked object. So if you use the .UID expression after a create object action, it returns the UID of the object you just created. Does that do what you want?
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Fri Sep 16, 2011 12:13 am

Yes, you're right! Thank you once again, and could you assist me with the array issue? I'm not sure if it's ignorance on my part or a bug.
B
5
S
2
G
3
Posts: 36
Reputation: 1,622

Post » Fri Sep 16, 2011 12:17 am

Works fine for me. It's helpful to always post a .capx showing what you're doing. That file I just linked to shows it working just fine so I'd have to see your file to be able to tell what's wrong.
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Fri Sep 16, 2011 12:22 am

haha Ashley you saved that file with r56 ;P
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Fri Sep 16, 2011 12:24 am

Woops :P well... if you could show me a .capx of it not working then that would be handy :)

(p.s. not long now...)Ashley2011-09-16 00:25:03
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Fri Sep 16, 2011 7:17 pm

I get an error saying that yours was saved in the r56 version and I can't open it because I'm running r55 even though it's the most up-to-date version available on the website. I'm going to guess it's because you're using a slightly more advanced dev version of Scirra.

EDIT: And someone beat me to the punchline, one sec I'm uploading.


EDIT EDIT: Here's the full project since when I tried to replicate the situation in a blank project it worked fine. Run the Combat_Test layout.
Linkkabuto2022011-09-16 19:35:07
B
5
S
2
G
3
Posts: 36
Reputation: 1,622

Post » Sun Sep 18, 2011 4:28 am

Bump
B
5
S
2
G
3
Posts: 36
Reputation: 1,622

Post » Sun Sep 18, 2011 2:34 pm

I'm looking at your .capx but I'm not sure what it's supposed to be doing so I can't tell if anything's broken or working. Please read tips for posting.

Are you aware: an array sized N by 0 by 0 has a total of N x 0 x 0 elements, which is 0 elements, which means you can never read or write any values in the array. It has no elements! If you want a one dimensional array, you must size it N x 1 x 1.Ashley2011-09-18 14:35:25
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Sun Sep 18, 2011 3:13 pm

And there's the source of the problem, thanks again :D
B
5
S
2
G
3
Posts: 36
Reputation: 1,622

Next

Return to How do I....?

Who is online

Users browsing this forum: WhosWho and 17 guests