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
36
S
7
G
9
Posts: 1,217
Reputation: 7,835

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 ImageImage
B
166
S
49
G
154
Posts: 8,103
Reputation: 100,227

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
139
S
70
G
17
Posts: 1,770
Reputation: 20,380

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
36
S
7
G
9
Posts: 1,217
Reputation: 7,835

Post » Thu Sep 10, 2009 9:29 pm

he means destroy by name
or pick by name
Spriter Dev
B
97
S
21
G
12
Posts: 3,259
Reputation: 16,844

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 ImageImage
B
166
S
49
G
154
Posts: 8,103
Reputation: 100,227

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