Expression to select object instead of selecting from list

Get help using Construct 2

Post » Fri Apr 18, 2014 8:15 pm

Hello,
Construct 2 is a great program and I know it's impossible to please everyone, but this little feature could save hundreds of "lines" of code...

Say, if instead of the menu that appears when you are selecting an object, you could instead select it by an expression?
Image

What I'm trying to do is:
I'm trying to create at runtime a chain that is made of blocks that goes from point A to B and they're all instances of the same object. They also are meant to be joint by the physics behavior.

How do I accomplish this? I want to make a code that is more reusable than creating the joints one by one.
B
6
S
1
G
2
Posts: 26
Reputation: 1,477

Post » Fri Apr 18, 2014 8:20 pm

If I understand your problem correctly, what you need to do is to put them all in to one or couple of families ( depending on what types of objects are they ) and just select those families.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
29
G
22
Posts: 1,984
Reputation: 19,997

Post » Fri Apr 18, 2014 8:43 pm

I thought about families, but it would not prove to be the best solution.
You see, think about a chain. This chain will go from point A to B.

What I'm trying to do is, by loops, creating the links at runtime by just passing the position of A and B and bound each one of those by a joint.

So the first will be bound to the second, while the second will be bound to the first and the third, and so on...

The code would look something like this:

While Chain.Index > 0 do:
Chain(ObjectsCount) Create physics joint to Object(ObjectsCount+1)
Add 1 to ObjectsCount

But my attempts so far have proven fruitless, no matter how I try to approach it.
B
6
S
1
G
2
Posts: 26
Reputation: 1,477

Post » Fri Apr 18, 2014 9:14 pm

Can i have a look at your capx then if you made it in r163. You could pm it to me.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
29
G
22
Posts: 1,984
Reputation: 19,997

Post » Fri Apr 18, 2014 9:21 pm

Sadly, I have already saved over the cap with a more raw approach(linking each one by an event...)
I couldn`t make it work because there was no such selector, but anyway, I can recreate it and post it here so everyone can learn.
But there`s no need for hiding the code.

I have now the last beta r167.2

Oh, and of course, thanks for at least try.

EDIT: Here it goes, the cap made in r167.2
You do not have the required permissions to view the files attached to this post.
B
6
S
1
G
2
Posts: 26
Reputation: 1,477

Post » Fri Apr 18, 2014 10:09 pm

But i can't open it I'm afraid because I don't have the latest beta! Maybe make a screenshot then?
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
29
G
22
Posts: 1,984
Reputation: 19,997

Post » Fri Apr 18, 2014 10:19 pm

While I'm downloading and porting the code to the 163, I made this sshot:
http://s8.postimg.org/wt1enjzph/lamp.jpg

The code is not finished so I didn't bother to actually make the spawning of chains to stop once it reaches the top.
B
6
S
1
G
2
Posts: 26
Reputation: 1,477

Post » Fri Apr 18, 2014 10:26 pm

ok, I'll wait.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
29
G
22
Posts: 1,984
Reputation: 19,997

Post » Fri Apr 18, 2014 10:40 pm

I just changed the saved version parameter in the xml and now it's opening fine in 163.

Here it goes
You do not have the required permissions to view the files attached to this post.
B
6
S
1
G
2
Posts: 26
Reputation: 1,477

Post » Fri Apr 18, 2014 10:56 pm

I'm not sure what you're trying to achieve here tbh. Could try and explain it in step by step form?
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
29
G
22
Posts: 1,984
Reputation: 19,997

Next

Return to How do I....?

Who is online

Users browsing this forum: Lancifer, Nicolas951, Shenkai the ssj and 25 guests