Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (NewbieZorro, TipmyPip, 1 invisible), 19,045 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Problem with event function! #262688
04/25/09 08:06
04/25/09 08:06
Joined: Feb 2009
Posts: 5
D
DaanGroot Offline OP
Newbie
DaanGroot  Offline OP
Newbie
D

Joined: Feb 2009
Posts: 5
Hi all,

I have a question cuz something in my script doesn't work, but it don't give an error.
The script is for a laserbullet. The laserbullet is a invisible box obj that has a local_number var so that all the effects are attached to a different box. The basic script goes like this:

Code:
function hit_event(local_laserball_number)
{
	if (event_type == EVENT_BLOCK)
	{
   		effect(laserball_explo_effect,15,my.x,normal);
	   	laserball_effect_destroy(local_laserball_number);
   		wait(1);
	   	ent_remove(me);
	}
	if (event_type == EVENT_ENTITY)
	{
   		effect(laserball_explo_effect,15,my.x,normal);
	   	laserball_effect_destroy(local_laserball_number);
   		wait(1);
   		ent_remove(me);
	}
}

action laserball
{
	var local_laserball_number = 1; // for instance

	my.INVISIBLE = ON;
	
	my.ENABLE_BLOCK = ON;
	my.ENABLE_ENTITY = ON;
	my.EVENT = hit_event(local_laserball_number);

	while (my != NULL)
	{
		c_move(me, laserball_move, NULLVECTOR, ACTIVATE_TRIGGER|GLIDE);

		wait(1);
	}
}


Somehow it does not work if the my.EVENT = hit_event(local_laserball_number); but it works with my.EVENT = hit_event; whithout any () or (local_laserball_number)

I do not know why it should make a difference. Is there a solucion for this? Because if there is not I have no idea how to store local variables in functions!
If somebody could help me explain this problem I would apreciate that very much =]

(Sorry for my bad Englisch, its not my first language)

Re: Problem with event function! [Re: DaanGroot] #262690
04/25/09 08:19
04/25/09 08:19
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
I dont understand why you dont get a compile error, just a c-script thing I spose.
But the important thing to remember is that you CANNOT pass parameters to an event!
All you can do is store the value into one of the entities skills, then the event
can get to it using the MY or ME pointer.
Like so...
Code:
function hit_event(local_laserball_number)
{
	if (event_type == EVENT_BLOCK)
	{
   		effect(laserball_explo_effect,15,my.x,normal);
	   	laserball_effect_destroy(my.skill33);   //use instance number stored in skill33
   		wait(1);
	   	ent_remove(me);
	}
	if (event_type == EVENT_ENTITY)
	{
   		effect(laserball_explo_effect,15,my.x,normal);
	   	laserball_effect_destroy(my.skill33);   //use instance number stored in skill33
   		wait(1);
   		ent_remove(me);
	}
}

action laserball
{
	wait(1);            //always a good idea on any action
	my.skill33 = 1;     //for storing instance number skill 1 to 40 is available below version A6.2
                              //skills 1 to 100 is available at or above version A6.2

	my.INVISIBLE = ON;
	
	my.ENABLE_BLOCK = ON;
	my.ENABLE_ENTITY = ON;
	my.EVENT = hit_event(my.skill33);

	while (my != NULL)
	{
		c_move(me, laserball_move, NULLVECTOR, ACTIVATE_TRIGGER|GLIDE);

		wait(1);
	}
}



"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Problem with event function! [Re: EvilSOB] #262691
04/25/09 08:27
04/25/09 08:27
Joined: Feb 2009
Posts: 5
D
DaanGroot Offline OP
Newbie
DaanGroot  Offline OP
Newbie
D

Joined: Feb 2009
Posts: 5
Thank you!
I tried what you said and it worked =]
problem solved!

Re: Problem with event function! [Re: DaanGroot] #262693
04/25/09 08:42
04/25/09 08:42
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
No problems smile Welcome aboard.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

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

Gamestudio download | 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