We can't seem to figure this one out, though I guess the answer is prett simple.
The below code should - in my oppinion - stop counting up my_temp[0] as soon as "t" is pressed. When t is pressed, the entity counter in the F11 debug panel is set back to 0, so the entity IS removed. Still, the function which I passed the entity to keeps running.
I don't understand why I can manipulate inLight fine (inLight.x += time_step; for example) but inLight != NULL never returns 0, even when the entity does no longer exist.
Funny thing: my_temp[0] gets reset to 0 when I press t, but then keeps counting up. it's like the real entity is removed but replaced by some fake entity so the function can keep running?
var my_temp[9];
FONT* fallbackFont = "Arial#12b"; // truetype font
PANEL* deb_pan = {
pos_x = 20;
pos_y = 300;
layer = 1200;
digits = 0,12,8.4,fallbackFont,1,my_temp[0];
}
void runWhileEntity(ENTITY* inLight)
{
while(inLight != NULL)
{
inLight.x += time_step;
my_temp[0] = inLight.x;
}
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);
ent_remove(theEnt);
}