Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,014 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
my.event question #292393
10/02/09 21:35
10/02/09 21:35
Joined: Jan 2005
Posts: 267
the Netherlands
Paulo Offline OP
Member
Paulo  Offline OP
Member

Joined: Jan 2005
Posts: 267
the Netherlands
Hi,

I've just created a piece of code that works. But the manual says that it's not a good idea.
Quote:
The event function itself should be simple. It normally should only transfer information to the entities' main function - it shouldn't perform instructions that can trigger events itself, displace entities, start particles or change anything else in the level. Thus instructions like c_move, ent_create, ptr_remove, c_trace etc. must not be performed. If the event function must perform such 'critical instructions', precede them by a wait(1) for delaying them to the next frame. Then it's safe.


In the event function I'm using a while loop, particles and ptr_remove. My idea is I'm only calling the event function 1 time, and not every frame therefore there shouldn't be any problem, right?? Imo cause I'm setting the passble and the invisible the event function turns into a normal function. But I'm really not sure at all. Could some1 correct me or agree?

Code:

Code:
function rocket_handle()
{
	set(my, PASSABLE | INVISIBLE);
	var exposion_time = 0;
	while(exposion_time < 5)
	{
		// call function destroy_rocket each frame, generating 3 particle at the position of the entity (my.x)
	   effect(destroy_rocket, 3, my.x, nullvector);
	   exposion_time +=1;
	   
	   wait(1);	
	}
	
	ptr_remove(me);
}

function enemy_rocket_movement()
{
	my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY); // Makes entity sensitive for block and entity collision
   my.event = rocket_handle;
	
	while(1)
	{
		c_move(my,vector(30*time_step,0,0),nullvector,IGNORE_PASSABLE | GLIDE | IGNORE_FLAG2 | ACTIVATE_PUSH); //moves the rocket
		wait(1);
	}
}




The more you have.. the more you can lose...
Dont tell em all you know.....
Re: my.event question [Re: Paulo] #292394
10/02/09 22:09
10/02/09 22:09
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
IMHO, what youve got is safe enough.
You have disabled the 'parent' entity from causing any more events,
and nothing the event itself does can cause any events.
Look safe to me...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: my.event question [Re: EvilSOB] #292396
10/02/09 22:21
10/02/09 22:21
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
function rocket_handle() {

=>>> my.event = NULL; <===

set(my, PASSABLE | INVISIBLE);

as safe as it can be!


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: my.event question [Re: Superku] #292424
10/03/09 12:28
10/03/09 12:28
Joined: Jan 2005
Posts: 267
the Netherlands
Paulo Offline OP
Member
Paulo  Offline OP
Member

Joined: Jan 2005
Posts: 267
the Netherlands
thanks a lot guys! laugh


The more you have.. the more you can lose...
Dont tell em all you know.....

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