Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

What's wrong with my while loops?

2 replies · 1,299 views · Started 31 May 2008

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:

You also can't declare an ffc as an argument as far as I'm aware.
They can only be floats or integers.

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.