Sarven Sentry help


#1

When I build a fence my code traps me outside of the fence(on the wrong side) but beside that the only other trouble im having is my dexterity

loop {
    flagGreen = this.findFlag("green");
    flagBlack = this.findFlag("black");
    flagViolet = this.findFlag("violet");
    if(flagGreen){
        this.pickUpFlag(flagGreen);
        this.buildXY("fence", this.pos.x,this.pos.y);
    }
    if(flagBlack){
        this.pickUpFlag(flagBlack);
        this.buildXY("fire-trap", this.pos.x,this.pos.y);
    }
    if(flagViolet){
        this.pickUpFlag(flagViolet);
        
    }
/*
    If there's a green flag, build a fence.
    If there's a black flag, build a fire-trap.
    If there's a violet flag, just move to its location.
    Remember to pick up flags after you're done with them!
*/  
}

#2

Feinty, you’re here long enough to know about the ```-codeblocks…


You’re problem is that you build the fence on your position. The game then tries to resolve your collision with the new wall, and places you somewhere around it. For example on the wrong side.

That is at least my guess. Try the following code (the difference is that I use the flag.pos, not this.pos):

loop{
    flagGreen = this.findFlag("green");
    flagBlack = this.findFlag("black");
    flagViolet = this.findFlag("violet");
    
    // If there's a green flag, build a fence.
    if (flagGreen){
        this.buildXY("fence", flagGreen.pos.x, flagGreen.pos.y);
        this.pickUpFlag(flagGreen);
    }
    // If there's a black flag, build a fire trap.
    else if (flagBlack){
        this.buildXY("fire-trap", flagBlack.pos.x, flagBlack.pos.y);
        this.pickUpFlag(flagBlack);
    }
    // If there's a violet flag, just move to its location.
    else if (flagViolet){
        this.pickUpFlag(flagViolet);
    }
    // Addition by me: Move back to center
    else{
        this.moveXY(43, 31);
    }
}

#3

It works now
this.say("thanks");