Joe123
07-11-2008, 01:02 PM
I'm posting this, partly because then I can't ever loose it, and partly because some other people may also find it useful, although probably not in it's current form.
I needed a 'suction' script, so after quite a bit of trawling through topics, I found one by Linkus, but it didn't really work properly, so I've re-written it to function nicely.
So Linkus helped, and I also used a bit of code that jman posted from the source code as a guide too.
Anyway;
ffc script vacuum{
void run(){
int angle; int xdifference; int ydifference;
while(true){
xdifference = this->X-Link->X;
ydifference = this->Y-Link->Y;
angle = ArcTan(ydifference,xdifference);
if(angle<0) angle += 2*PI;
if(angle==PI) this->X++;
else if(angle==PI/2) this->Y--;
else if(angle==PI*3/2) this->Y++;
else if(angle==0 || angle==2*PI) this->X--;
else if(angle<PI/2){this->X--;this->Y--;}
else if(angle<PI){this->X--;this->Y++;}
else if(angle<PI*3/2){this->X++;this->Y++;}
else{this->X++;this->Y--;}
Waitframes(3);
}
}
}
Sucks the ffc with the script attached over to Link.
Not really all that useful, but quite fun to watch for a bit, and I'm sure if anyone else needed a suction script, it'd be good for reference.
I needed a 'suction' script, so after quite a bit of trawling through topics, I found one by Linkus, but it didn't really work properly, so I've re-written it to function nicely.
So Linkus helped, and I also used a bit of code that jman posted from the source code as a guide too.
Anyway;
ffc script vacuum{
void run(){
int angle; int xdifference; int ydifference;
while(true){
xdifference = this->X-Link->X;
ydifference = this->Y-Link->Y;
angle = ArcTan(ydifference,xdifference);
if(angle<0) angle += 2*PI;
if(angle==PI) this->X++;
else if(angle==PI/2) this->Y--;
else if(angle==PI*3/2) this->Y++;
else if(angle==0 || angle==2*PI) this->X--;
else if(angle<PI/2){this->X--;this->Y--;}
else if(angle<PI){this->X--;this->Y++;}
else if(angle<PI*3/2){this->X++;this->Y++;}
else{this->X++;this->Y--;}
Waitframes(3);
}
}
}
Sucks the ffc with the script attached over to Link.
Not really all that useful, but quite fun to watch for a bit, and I'm sure if anyone else needed a suction script, it'd be good for reference.