Sarven sentry level or compiler expected to be broken


#1

I believe the compiler on this level is broken. I have created code similar to what the video displays, and the compiler kept giving me the issue, “expected an identifier and instead saw if.” I see no problem with the code I have. After my first attempt I decided to use the videos help code. And i’m still receiving the same compiler error,“expected an identifier and instead saw if.” Here is my code // Use different colored flags to perform different tasks.

loop {
var flagGreen = this.findFlag(“green”);
var flagBlack = this.findFlag(“black”);

// If there's a flagGreen...
-if flagGreen: 
    greenPos = flagGreen.pos;
    greenX = greenPos.x; 
    greenY = greenPos.y; 
    self.this.buildXY("fence", greenX, greenY);

    // Build a fence at flagGreen's position.
    this.buildXY("fence", 36, 30);   
    // Pick up the flag!
this.pickUpFlag(flagGreen);

// If there's a flagBlack...
if (flagBlack) {
    blackPos = flagBlack.pos;
    blackX = blackPos.x;
    blackY = blackPos.y;
    
    // Build a fire-trap at flagBlack's position.
    this.buildXY("fire-trap",blackX, blackY);
   
    // Pick up the flag!
    this.pickUpFlag(flagBlack);
// Move back to the center.
this.moveXY(43, 31);

}
}


#2

You have a dash sign (-) before the if in the if flagGreen: line. Please be attentions to these small details. :wink:

Also, it looks like you have mixed some Python syntax with your JavaScript (or the other way around). Revise your if block syntax and whether you should be using self or this (not both).


#3

Yea I was using javascript syntax and when I used the video’s help code I didn’t realize it was written in python. My if statement looked like this if (){
}

oh my goodness, I didn’t even see that dash you have got to be kidding me haha.