Is there a way to check if an instance was deactivated or destroyed?

L

Leandro

Guest
Hey guys,

Do you know if it is possible to check if an instance was deactivated instead of destroyed?
instance_exists() won't do the trick.

Thanks!
;)
 
G

Greenhawk

Guest
What's up, man! :)

Hmmm. Well for instances destroyed, you can use
Code:
if !instance_exists(threatuna)
{

instance_create(x,y,inhale_tuna)
}
the key is to use the '!" before the command to signify the "not" portion. I'm trying to figure out how you said that won't work. What is it that you're doing in your project? it should work for deactivated objects too, but i'm not entirely sure.
 
S

Snail Man

Guest
You could write to a global list whenever an object is deactivated, then remove it when deactivated. That way you can just check if the instance doesn't exist and isn't on the list, you know it's gone for good
 
N

NPT

Guest
You can access a deactivated instance by its instance ID.

From the manual:

A deactivated instance effectively ceases to exist in the game, but individual instances can still have their variables accessed. You cannot use with(object) or with(instance) however, but rather you must access the instance directly using it's unique id in the following form:

val = inst.variable;

In the above example, "inst" would be a variable that holds the id of the deactivated instance, and this is the only way that a deactivated instance can be referenced without it being activated previously.
 
L

Leandro

Guest
What's up, man! :)

Hmmm. Well for instances destroyed, you can use
Code:
if !instance_exists(threatuna)
{
[QUOTE="Greenhawk, post: 3254, member: 53"]What's up, man! :)

Hmmm. Well for instances destroyed, you can use
[CODE]if !instance_exists(threatuna)
{

instance_create(x,y,inhale_tuna)
}
the key is to use the '!" before the command to signify the "not" portion. I'm trying to figure out how you said that won't work. What is it that you're doing in your project? it should work for deactivated objects too, but i'm not entirely sure.
You could write to a global list whenever an object is deactivated, then remove it when deactivated. That way you can just check if the instance doesn't exist and isn't on the list, you know it's gone for good
You can access a deactivated instance by its instance ID.

From the manual:

Hey Guys, thanks for the reply.

Greenhawk, I was trying to understand if there is a build in way to check if an instance was deactivated or destroyed.
I was hopping there was a simpler way to do that. But I will probably go for the solution that Snail Man just gave.
Btw, NPT I knew about that. it works if the instance was deactivated, but if you try to check that on an instance that was destroyed you get a run time error.
But thanks for pointing out, anyways!
;)

Thanks again guys,

Cheers
 
Top