Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Akow), 1,371 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
ent_remove & ent_create #357008
02/05/11 07:11
02/05/11 07:11
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
hi..

how can i make an object remove when it is eaten and how can i make it appear again after 15 sec.? i tried to use ent_remove and ent_create but the program is crashing. im trying to put it in this script:
Code:
if(froze == 1)
{
 set(my, PASSABLE);
 set(my, UNLIT | BRIGHT  | PASSABLE);   
 my.skin = 2;
 my.lightrange = 200;
 my.ambient = 100;
 my.blue = 200;

  while (vec_dist(player.x, my.x) > 80)  // wait until the player comes close
	{
          wait (1);
	}
  set(my, INVISIBLE);
  ent_remove(my);

 wait(-15);
 ent_create(ghost, vector(-608, 1072, 780), ghost1);			
 froze = 0;
 my.skin = 1;
 my.lightrange = 0;
 my.ambient = 0;
 my.state = 0;
}



@ this part of the code, what i want the enemy to do is to freeze for 15 sec. whenever the player gets an object. @ this point, the enemy can now be eaten by the player. and thats my problem, whenever the player ate the enemy it will be invisible and removed but it was never been created. frown

pls someone help me..thanks

Re: ent_remove & ent_create [Re: carla_mariz] #357014
02/05/11 08:27
02/05/11 08:27
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline
Expert
fogman  Offline
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
When you remove an entity its function will terminated after the next
wait cycle.

You could try to make it PASSABLE as well, without removing it.

Also you do a ent_remove(my), but you try to use it afterwards.
Won´t work, because my is empty then.



no science involved
Re: ent_remove & ent_create [Re: carla_mariz] #357016
02/05/11 08:40
02/05/11 08:40
Joined: Jan 2011
Posts: 120
United States
Logan Offline
Member
Logan  Offline
Member

Joined: Jan 2011
Posts: 120
United States
Your problem is that you are using the "my" pointer after you use ent_remove(my). This is the number one thing you have to be careful with about ent_remove. You can never access that entity via pointer again, because it no longer exists--so if you ent_remove(my), and then try to set my.skin, my.lightrange, my.ambient etc a few lines later, the engine doesn't know what you're talking about, because "my" no longer exists.

It looks like you assumed ent_create() restores the "my" pointer. Easy mistake. But it doesn't, unless you specifically set it.

my = ent_create(ghost, vector(-608, 1072, 780), ghost1);

OR

My recommendation is that you do not use ent_remove or ent_create at all. These commands are slow and make things unnecessarily complicated--like with the pointers thing I was describing above. It'd be easier to just set the entity INVISIBLE and PASSABLE for 15 seconds, so it looks like he's gone, without actually removing him. Save ent_remove for the times where he's really NEVER going to appear again.

One more thing, if you stick with the ent_remove technique, you may have to set proc_mode = PROC_GLOBAL at the beginning of the function, so the function doesn't end right when you remove the my entity.

Re: ent_remove & ent_create [Re: fogman] #357017
02/05/11 08:45
02/05/11 08:45
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
hmmm..what if i just make it invisible?

set(my, INVISIBLE);

and then set into VISIBLE again after 15 sec. will it work? and by the way, what is the counter part code of INVISIBLE? i tried visible but it does not work.

set(my, VISIBLE);

im just using a7 free.

thanks!

Re: ent_remove & ent_create [Re: carla_mariz] #357019
02/05/11 08:50
02/05/11 08:50
Joined: Jan 2011
Posts: 120
United States
Logan Offline
Member
Logan  Offline
Member

Joined: Jan 2011
Posts: 120
United States
set(my, INVISIBLE); // sets the entity invisible

reset(my, INVISIBLE); // sets the entity visible

Just turn INVISIBLE on and off--stay away from VISIBLE, that's another story. laugh

Re: ent_remove & ent_create [Re: Logan] #357020
02/05/11 08:54
02/05/11 08:54
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
oh..that makes me soooo noob..lol..thanks grin

Re: ent_remove & ent_create [Re: carla_mariz] #357021
02/05/11 08:58
02/05/11 08:58
Joined: Jan 2011
Posts: 120
United States
Logan Offline
Member
Logan  Offline
Member

Joined: Jan 2011
Posts: 120
United States
Ha no worries at all. I've always thought it was counter-intuitive that you have to turn a flag OFF to set an entity to be visible. It makes sense where the confusion came from.

Re: ent_remove & ent_create [Re: Logan] #357024
02/05/11 09:10
02/05/11 09:10
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
oh no..another problem again..hmmmmnn..
my code now looked like this:

Code:
if(froze == 1)
{
 set(my, PASSABLE);
 set(my, UNLIT | BRIGHT  | PASSABLE);   
 my.skin = 2;
 my.lightrange = 200;
 my.ambient = 100;
 my.blue = 200;

 while (vec_dist(player.x, my.x) > 80)  // wait until the player comes close
 {
   wait (1);
 }
 set(my, INVISIBLE);

 wait(-15);
 reset(my, INVISIBLE);
 froze = 0;
 my.skin = 1;
 my.lightrange = 0;
 my.ambient = 0;
 my.state = 0;
}



the ghosts freezes but if they are not eaten after 15 sec, they are still not moving. i think the problem is in the while because the rest of the lines under it is not terminated. frown

Re: ent_remove & ent_create [Re: carla_mariz] #357128
02/05/11 18:03
02/05/11 18:03
Joined: Jan 2011
Posts: 120
United States
Logan Offline
Member
Logan  Offline
Member

Joined: Jan 2011
Posts: 120
United States
So, I'm sorry. This whole time I've been a little bit unclear on exactly what you want this function to do. That would help in figuring out what is going wrong. laugh

Re: ent_remove & ent_create [Re: Logan] #357211
02/06/11 04:28
02/06/11 04:28
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
any idea on can i make it?? frown

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1