|
[C-Script] Stroboscope
#263997
05/03/09 18:09
05/03/09 18:09
|
Joined: Aug 2006
Posts: 96 Netherlands
Polypfreak1987
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2006
Posts: 96
Netherlands
|
Hello everbody, I want to make a stroboscope. I have a model with an action:
action stroboscoop {
while(1) {
if(key_space == 1) {
strobo();
}
wait(1);
}
}
And the following function:
function strobo() {
vec_set(my.blue,vector(255,255,255));
if(key_space == 1) {
while(1) {
my.lightrange = 200;
wait(-0.01);
my.lightrange = 0;
wait(-0.01);
}
}
}
When I press the spacebar the light will flicker. But when I release the spacebar the light continues flickering. Does anybody know how to stop that? So when I press the spacebar. The light will flicker as long the spacebar is pressed. When I release the spacebar, the flicker will stop. I hope you can help me out. Thanks in advance.
|
|
|
Re: [C-Script] Stroboscope
[Re: Polypfreak1987]
#264012
05/03/09 19:36
05/03/09 19:36
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
maybe this helps:
while (1)
{
if (key_space)
{
strobo();
while (key_space) wait(1); // wait here untill key_space = 0, strobo() would be call only one time.
}
wait(1);
}
Last edited by Widi; 05/03/09 19:42.
|
|
|
Re: [C-Script] Stroboscope
[Re: Polypfreak1987]
#264721
05/07/09 19:29
05/07/09 19:29
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
Expert
|
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
I think the problem was that you were calling the function strobo whenever key_space was pressed, since you held the spacebar down, it was called anew every frame, so the line:vec_set(my.blue,vector(255,255,255)); was executed every frame and then it doesn't flicker.
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
|