2(script-)problems

Posted By: Scorpion

2(script-)problems - 12/01/07 17:44

hello,
I tried a lot around and I'm not able to solve this problems.
The first one is a little function that _should_ spawn entities in one line from one position to another one.

Code:
unction felsSpitzen(VECTOR* startPos,VECTOR* endPos)
{
VECTOR tempPos;
VECTOR addPos;
vec_set(addPos,endPos);
vec_sub(addPos,startPos);
vec_normalize(addPos,50);
vec_set(tempPos,startPos);
while(vec_dist(tempPos,endPos)>25)
{
ent_create("felsen.mdl",tempPos,felsMoveOut);
vec_add(tempPos,addPos);
wait(-random(0.05));
}
}



it spawns them correctly, but it don't stop spawning them, if they reached the end-position.If i comment out the wait() everything works property.

My second problem is, that a function(main) I use to check if a key is pressed is closed if I call another function.
I left out all unimportant parts. If I comment out the ent_remove everything works fine.
Code:
function flash_func()
{
set(my,BRIGHT | TRANSLUCENT);
my.alpha = 100;
while(my.alpha>0)
{
my.alpha -= 7*time_step;
wait(1);
}
ent_remove(me);
}

function spawn_flash(VECTOR* position)
{
me = ent_create("lightning2.tga",position,flash_func);
}

int main()
{
[...]
while(1)
{
if(key_l)
{
spawn_flash(nullvector);
while(key_l){wait(1);}
}
wait(1);
}
return 0;
}


Posted By: flits

Re: 2(script-)problems - 12/01/07 18:31

int main()
{
var cr;
[...]
while(1)
{
if(key_l == 1 && cr ==1)
{
spawn_flash(nullvector);
cr =0;
}
if(key_l == 0)
{
cr =1;
}

}
wait(1);
}
return 0;
}
Posted By: Scorpion

Re: 2(script-)problems - 12/01/07 22:00

that really does not solve the problem.
All in all the mainfunction works, it also calls the funtion if i press l, the problem is, that it is killed after that.

If i call any other function it works without any problems.

EDIT: I found out, that the first Problem doesn't occur, if I comment out the wait()..
Posted By: RedPhoenix

Re: 2(script-)problems - 12/02/07 10:59

you move the creator with 50 per wait unit, but your vec_dist searches only in an range of 25. This COULD cause the problem, if the creator has an 25dividable distance to the endpos.
Posted By: Scorpion

Re: 2(script-)problems - 12/02/07 12:46

nope, that is correct. The distance can be just as half big as the distance to move. When I set it to 50 it still don't work... and like i said already: it works great if I don't use the wait()
Posted By: Altimeter

Re: 2(script-)problems - 12/02/07 16:03

-just for debugging: try to replace
wait(-random(0.05));
by
wait(1);
or by
wait(-0.05);
does it work?
-how many entities are created, when you comment the wait(...) out?
Is it as much as expected or are that many, but at the same place?
Posted By: Scorpion

Re: 2(script-)problems - 12/02/07 16:30

oh my god, its really weird today, my SED went crazy, it saves files not or just in parts. My WED compiles the level just sometimes. and this 1. problem was solved by itsself, but there is still the other one left... but still thank you for the help from you already

EDIT: i found a walk-around for the 2. problem. I used the you-pointer instead of "my" but i don't see i reason why that is necessary...

SO the Problems are gone..also if i don't know why...thank you for the time you spend on that thread, wihs me luck that they don't appear again :S
© 2024 lite-C Forums