2 registered members (AndrewAMD, ozgur),
1,415
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Managing objects[scene objects]
#265558
05/13/09 05:51
05/13/09 05:51
|
Joined: Apr 2009
Posts: 298 Southern Oceans
KiwiBoy
OP
Member
|
OP
Member
Joined: Apr 2009
Posts: 298
Southern Oceans
|
Hey folks, Been trying to adapt a script from a buddy that creates an object, controlls its alpha and removes it from the scene when no longer required to be ready again to recreate. Most of it is working fine EXCEPT that when the object is assigned its action/function, the functions never stop. Having worked at this all day I can no longer see straight so if anyone could help me out here I would feel indebted.
var MKt1 = 1;
function remove_t1();
function tree1();
ENTITY* marker;
#define health skill40
function tree1()
{
while(player == NULL){wait(1);}
my.red = 200;
my.green = 220;
my.blue = 200;
set(my, TRANSLUCENT);
my.alpha = 0;
set(my, PASSABLE);
set(my, SHADOW);
my.health = 100;
while (1)
{
while (vec_dist(my.x, player.x) > 800){wait(1);}
if ((vec_dist(my.x, player.x) < 800) && (MKt1 ==0))
{
if(my.alpha < 100)
{
my.alpha += 15 * time_step;
if(my.alpha > 100)
{
my.alpha = 100;
}
}
}
else
{
my.alpha -= 5 * time_step;
my.health -= 5 * time_step;
if((my.alpha < 0)&&(my.health < 0))
{
my.alpha = 0;
my.health = 0;
}
}
wait (1);
remove_t1();
}
}
function remove_t1()
{
while(vec_dist(my.x, player.x) < 900){wait(1);}
if ((vec_dist(my.x, player.x) > 900)&&(MKt1 ==0))
{
if((my.health)&&(my.alpha))
{
my.health = 0;
my.alpha = 0;
wait(-1);
ent_remove(me);
MKt1 = 1;
}
}
}
action makem()
{
while(player == NULL){wait(1);}
marker = me;
set(my, PASSABLE);
while(1)
{
if((vec_dist(my.x, player.x) < 800) && (MKt1 == 1))
{
ent_create ("cbabe_unanim.mdl", vector(-3554.000, 39.000, -150.000), tree1);
MKt1 = 0;
}
wait(1);
}
}
The way it is written out now allows the script to work in a basic sense in that the expected behaviour is exhibited successfully but maybe thats why it dont work properly? Thanks....
|
|
|
Re: Managing objects[scene objects]
[Re: KiwiBoy]
#265594
05/13/09 09:32
05/13/09 09:32
|
Joined: May 2008
Posts: 331 Lithuania, Vilnius
Jaxas
Senior Member
|
Senior Member
Joined: May 2008
Posts: 331
Lithuania, Vilnius
|
don't use functions for object! use actions use watches in SED to track why function don't stop
The smaller the bug, the harder it is to kill. _________________________________________ Forklift DEMO (3dgs)
|
|
|
Re: Managing objects[scene objects]
[Re: Jaxas]
#265598
05/13/09 09:45
05/13/09 09:45
|
Joined: Apr 2009
Posts: 298 Southern Oceans
KiwiBoy
OP
Member
|
OP
Member
Joined: Apr 2009
Posts: 298
Southern Oceans
|
Thanks for reply. Took the hint and removed the while looop and so now the process functions that way as expected Thanks. Just have to tweak the alpha to work now and it will be spot on.
Last edited by KiwiBoy; 05/13/09 11:00.
|
|
|
Re: Managing objects[scene objects]SOLVED
[Re: KiwiBoy]
#265611
05/13/09 11:01
05/13/09 11:01
|
Joined: Apr 2009
Posts: 298 Southern Oceans
KiwiBoy
OP
Member
|
OP
Member
Joined: Apr 2009
Posts: 298
Southern Oceans
|
....Ok, solved all probs and script now works as expected.
action tree1()
{
while(player == NULL){wait(1);}
my.red = 200;//testing purposes
my.green = 220;//testing purposes
my.blue = 200;//testing purposes
set(my, TRANSLUCENT);
my.alpha = 0;
set(my, PASSABLE);
set(my, SHADOW);
while (1)
{
while (vec_dist(my.x, player.x) > 800){wait(1);}
if (vec_dist(my.x, player.x) < 800)
{
while(my.alpha < 100)
{
my.alpha += 5 * time_step;
if(my.alpha >= 100)
{
my.alpha = 100;
}
wait(1);
}
}
else
{
if((vec_dist(my.x, player.x) > 800)&&(my.alpha > 0))
{
my.alpha -= 5 * time_step;
my.health -= 5 * time_step;
if(my.alpha <= 0)
{
my.alpha = 0;
}
}
}
remove_t1();
return;
}
}
function remove_t1()
{
while(vec_dist(my.x, player.x) < 900){wait(1);}
if ((vec_dist(my.x, player.x) > 900)&&(MKt1 ==0))
{
if(my.alpha)
{
my.alpha = 0;
wait(-1);
ent_remove(me);
MKt1 = 1;
}
}
}
Last edited by KiwiBoy; 05/13/09 11:01.
|
|
|
|