Variables that can hold objects and objecttypes

Discussion and feedback on Construct 2

Post » Fri Aug 12, 2011 10:59 am

I was wondering if there were plans to have variables that aren't limited to numbers/text/boolean, but can also hold objects and objecttypes.

For Construct Classic you can basically do this with lucid's S plugin and I think it's an incredibly useful feature and therefore should be built-in.

I didn't follow C2 development as close as I should have, so chances are I might have missed discussion about this matter. Feel free to enlighten me.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Fri Aug 12, 2011 11:05 am

You can "store" an instance in a variable by storing its unique ID (UID) in a number variable. To get it back, you just use a 'pick by UID'.

You can also reference an object type simply by storing its name string in a text variable, but I'm not clear what you would want to do with that.

Similar techniques work in Classic. It's an interesting idea, but I'm not clear what it would allow you to do that you can't do with the above. How exactly will it work with the SOL/picking algorithms?
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Fri Aug 12, 2011 11:50 am

[QUOTE=Ashley] You can "store" an instance in a variable by storing its unique ID (UID) in a number variable. To get it back, you just use a 'pick by UID'.

You can also reference an object type simply by storing its name string in a text variable, but I'm not clear what you would want to do with that.

Similar techniques work in Classic. It's an interesting idea, but I'm not clear what it would allow you to do that you can't do with the above. How exactly will it work with the SOL/picking algorithms?[/QUOTE]

Fair enough, I think for most uses this would work perfectly well and using PVs with UIDs is being done in CC quite regularly, you're right. Maybe I was overthinking the matter.

Also these features exist in S not with simple variables, but one-dimensional arrays, which is a different story. Like iterating through a specific list of objects easily or saving/loading levels with a custom editor.

Maybe that's what should have been my intention with this thread: how about the superstructure kind of arrays/functionality for C2?
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Fri Aug 12, 2011 3:21 pm

I would think that the ability to add variables in events would work for that.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Wed Jun 27, 2012 8:17 pm

Hi Ashley,

What if I want to pick an object and join it with the parent. like the following

system | for each anchor
anchor | pick nearest to (anchor.x,anchor.y)
      Create revolute joint for the parent anchor with the picked one

I wish there is something like .parent
or if there is away to write some Javascript.
B
5
Posts: 19
Reputation: 770

Post » Wed Jun 27, 2012 8:31 pm

@haroonjoblo

This is a very old thread. If you have questions, you should make a post in the "How do I?" section of the forums. There are usually plenty of people who can offer help without us having to bother the only developer of the software.

As for your question, if you have a look at the "Example of realistic rope" thread in the FAQ, I think you'll find the solution to your problem.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452


Return to Construct 2 General

Who is online

Users browsing this forum: newt and 7 guests