Sarven Sentry Help Required


#1

Hi,
I have been play code combat for around 2 weeks and I am unfortunately stuck on Sarven Sentry. Could anybody help me please.

My Code -
loop:
flagGreen = self.findFlag(“green”)
flagBlack = self.findFlag(“black”)
flagViolet = self.findFlag(“violet”)

if flagGreen:
    if flagGreen.colour is "green":
        self.buildXY("fence", flagGreen.pos.x, flag.green.y)
        self.pickUpFlag("green")

if flagBlack:
    if flagBlack.colour is "black":
        self.buildXY("fire-trap", flagBlack.pos.x, flagBlack.pos.y)
        self.pickUpFlag("black")
        
if flagViolet:
    if flagViolet.colour is "violet":
        self.moveXY(flagViolet.pos.x, flagViolet.pos.y)
        self.pickUpFlag("violet")

My hero just can’t move. Help Pls.


#2

You can either pass a color to findFlag like flagGreen = self.findFlag("green"), which is the approach the sample code takes, or you can find a single flag and then check its color, whcih seems to be what you have added. Either works, but you don’t need both. The reason it’s not working is that you put flagGreen.colour instead of flagGreen.color–we are American so we have the variables named after the American spelling! So try taking that secondary color check out, or at least using the American speling, and you should be good to go to find the flags. The other thing is that you need to pass flagGreen to pickUpFlag instead of "green".


#3

thx bra ur da best
btw i got pass