2 registered members (7th_zorro, 1 invisible),
942
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
OP
Expert
|
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
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Then how about this...
#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
OP
Expert
|
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
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
If you dont like the "mess" in the 'main' function, how about this...
#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
Serious User
|
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:
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
Expert
|
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
#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
|
|
|
|