pick object by name

For questions about using Classic.

Post » Wed Sep 09, 2009 3:36 pm

Hi!

I need to pick an object, which name is in a global variable. For example:

Key space is pressed
-global (doomed): Destroy

is there any way to do this without having to create a PV and manually write the name in for each object?
B
8
S
2
G
5
Posts: 744
Reputation: 3,288

Post » Wed Sep 09, 2009 6:42 pm

how can an objects name be in a global variable?
I don't fully understand what you want, but it's probably better to give your objects a "name" private variable.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Wed Sep 09, 2009 6:49 pm

You might be able to work with the object ID (Object.OID).

If there's no other way to pick objects, you might be able to put them all in the same family, and pick by comparison, Family.OID Equal To Global('Stored OID').
B
3
S
1
G
3
Posts: 82
Reputation: 1,189

Post » Wed Sep 09, 2009 8:12 pm

There is system create, but no system destroy.
Might be useful tho....
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Wed Sep 09, 2009 10:53 pm

Well the thing is that for this engine i'm working on I'm trying to make everything to be as efficient as possible when i'm expanding the game later on. Right now i'm working on a weapons system, and without this option each weapon needs an extra private variable added, and so far everything is 100% free from unnescessary repetitions.

Is it hard to add? Because i've thought of it before, and i think it's really wierd that you type everything in eccept the objects that you have to pick from a list. Using calculations or values to pick objects looks to me like something that should have been there from the beginning.
B
8
S
2
G
5
Posts: 744
Reputation: 3,288

Post » Thu Sep 10, 2009 1:27 pm

The only way I can think of is to have each object that can be destroyed this way in a family, then when you compare the private variable to test if it = the global variable then you destroy it.
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Thu Sep 10, 2009 7:14 pm

yea, families are the way to go when you want expandability and all objects to behave in a similar fashion. Your setup sounds typical of a family usage.

and newt, what would system destroy do?
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Thu Sep 10, 2009 9:29 pm

he means destroy by name
or pick by name
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Thu Sep 10, 2009 9:36 pm

[quote="Davioware":944dah7h]yea, families are the way to go when you want expandability and all objects to behave in a similar fashion. Your setup sounds typical of a family usage.

and newt, what would system destroy do?[/quote:944dah7h]

Yeah opposite of system create object by name.
System destroy object by name, in this case he could actually destroy the object by referencing the global with the same name.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Thu Sep 10, 2009 10:47 pm

Exactly. Actually i think all object picking should be by name.

Edit: Creating an object was actually what i had to do. And it worked perfectly... so... yeah....

But i still think being able to pick objects through expressions all the time would be a better system.
B
8
S
2
G
5
Posts: 744
Reputation: 3,288

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests