PDA

View Full Version : What's wrong with my while loops?



thebetter1
05-31-2008, 01:42 PM
For some reason, the compiler doesn't like that I have left braces after my while loops. It tells me to put a semicolon after them instead, but then it interprets while as a function. Why won't it accept my left braces? It also does the same thing with the if loops.


import "std.zh"

ffc script Homing_on_X {
void run(ffc HomingFFC) {
While(true) {
If(Link->X < HomingFFC->X) {
HomingFFC->Vx = -5;
}
If(Link->X > HomingFFC->X) {
HomingFFC->Vx = 5;
}
If(Link->X == HomingFFC->X) {
HomingFFC->Vx = 0;
}
Waitframe();
}
}
}

Edit: I finally figured out that while can't be capitalized.:banghead:

Joe123
05-31-2008, 07:45 PM
You also can't declare an ffc as an argument as far as I'm aware.
They can only be floats or integers.

ScaryBinary
05-31-2008, 08:51 PM
Joe123 is correct. If you assign the script to the Homing FFC, though, you could do this:

import "std.zh"

ffc script Homing_on_X {
void run() {
while(true) {
if(Link->X < this->X) {
this->Vx = -5;
}
if(Link->X > this->X) {
this->Vx = 5;
}
if(Link->X == this->X) {
this->Vx = 0;
}
Waitframe();
}
}
}
(the "this" just refers to whatever FFC the script is assigned to.)

Otherwise, you could pass in the FFC id as the argument and then use Screen->LoadFFC(id).

Also note that your "if"s must be lowercase.