Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (7th_zorro, 1 invisible), 942 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Entity pointer passed to function [Re: Saturnus] #344439
10/17/10 13:03
10/17/10 13:03
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
Weird how I have once wondered the same thing...

Re: Entity pointer passed to function [Re: Joey] #344661
10/19/10 13:53
10/19/10 13:53
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline OP
Expert
Germanunkol  Offline OP
Expert

Joined: Jun 2006
Posts: 2,640
Earth
Thanks for the ideas, but none of them will work. I've tried the pointer to a pointer thing before posting. Also, the workarounds don't really work. The skill one won't work cause we don't wanna use an extra skill (it's a plugin which shouldn't use more than one skill) and "use fuction as the action of the entity and use a while-me loop instead?" won't work either cause this is already a simplified version of the whole setup... it would work here, but not with what we want, I believe.


~"I never let school interfere with my education"~
-Mark Twain
Re: Entity pointer passed to function [Re: Germanunkol] #344664
10/19/10 14:11
10/19/10 14:11
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Then how about this...
Code:
#define I_AM_ALIVE	(1<<30)   //unused entity flag bit

void runWhileEntity(ENTITY* inLight)
{
	while(is(inLight, I_AM_ALIVE))
	{
		inLight.x += time_step;
		my_temp[0] = inLight.x;
		wait(1);
	}
	beep();
	beep();
	beep();
}

void main()
{
	set(deb_pan,SHOW);
	level_load(NULL);
	wait(3);
	
	ENTITY* theEnt;
	theEnt = ent_create(NULL,nullvector,NULL);
	set(theEnt, I_AM_ALIVE);

	runWhileEntity(theEnt);
	while(key_t == OFF) wait(1);
	reset(inLight, I_AM_ALIVE);
	wait(1);   //still critical!
	ent_remove(theEnt);
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Entity pointer passed to function [Re: EvilSOB] #344737
10/20/10 08:12
10/20/10 08:12
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline OP
Expert
Germanunkol  Offline OP
Expert

Joined: Jun 2006
Posts: 2,640
Earth
Thanks, that is a way of doing it. Though annoying, I guess it'll work for now...


~"I never let school interfere with my education"~
-Mark Twain
Re: Entity pointer passed to function [Re: Germanunkol] #344741
10/20/10 09:00
10/20/10 09:00
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
If you dont like the "mess" in the 'main' function, how about this...
Code:
#define I_AM_DEAD	(1<<30)   //unused entity flag bit

void runWhileEntity(ENTITY* inLight)
{
	while(!is(inLight, I_AM_DEAD))
	{
		inLight.x += time_step;
		my_temp[0] = inLight.x;
		wait(1);
	}
	ent_remove(inLight);
	beep();
	beep();
	beep();
}

void main()
{
	set(deb_pan,SHOW);
	level_load(NULL);
	wait(3);
	
	ENTITY* theEnt;
	theEnt = ent_create(NULL,nullvector,NULL);

	runWhileEntity(theEnt);
	while(key_t == OFF) wait(1);
	set(inLight, I_AM_DEAD);
}



Or if its the "new" flag I_AM_WHATEVER that you dont like,
you could utilise one of the now almost-unused C-script FLAG1->FLAG8 flags.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Entity pointer passed to function [Re: EvilSOB] #344742
10/20/10 09:47
10/20/10 09:47
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline
Serious User
pegamode  Offline
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
What about passing the handle of the entity pointer into the function?

I'm not 100% sure, but wouldn't it be possible to use the my-pointer inside the function ( + proc_mode = PROC_GLOBAL; )?

Something like that:

Code:
void runWhileEntity(ENTITY* inLight)
{
proc_mode = PROC_GLOBAL;
my = inLight;
while (my) {
  ...
}
...
}



The my-pointer is restored correctly, isn't it?

Re: Entity pointer passed to function [Re: pegamode] #344747
10/20/10 10:34
10/20/10 10:34
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
BTW, you say you are already using one skill in the plugin...
What sort of data does it contain?
Could you pass a "kill" command through that skill?

eg
Code:
#define plugin_skill   "whichever skill the plugin is already using"

void runWhileEntity(ENTITY* inLight)
{
	while(inLight.plugin_skill != -999)
	{
		inLight.x += time_step;
		my_temp[0] = inLight.x;
		wait(1);
	}
	beep();
	beep();
	beep();
}

void main()
{
	set(deb_pan,SHOW);
	level_load(NULL);
	wait(3);
	
	ENTITY* theEnt;
	theEnt = ent_create(NULL,nullvector,NULL);

	runWhileEntity(theEnt);
	while(key_t == OFF) wait(1);
	theEnt.plugin_skill = -999;
	wait(1);	//critical wait
	ent_remove(theEnt);
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 2 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