Sarven Desert- Please help


#1

Can someone tell me what is wrong with my code please?

Use different colored flags to perform different tasks.

loop:

flagGreen = self.findFlag("green")
flagBlack = self.findFlag("black")
flagViolet = self.findFlag("violet")

self.findFlag("black")
if flagBlack:
    pos = flagBlack.pos
    x = pos.x
    y = pos.y
    self.buildXY("fire-trap", x, y)
    self.pickUpFlag(flagBlack)
self.findFlag("green")
if flagGreen:
    pos = flagGreen.pos
    x = pos.x
    y = pos.y
    flagGreen = self.buildXY("fence", x, y)
    self.pickUpFlag(flagGreen)
self.findFlag("violet")
if flagViolet:
    pos = flagViolet.pos
    x = pos.x
    y = pos.y
    self.moveXY(x, y)
    self.pickUpFlag(flagViolet)

#2

Just remove the line in front of your if statement (self.findFlag(“black”)), you don’t need that. For example:

flagGreen = self.findFlag("green")

if flagGreen:
    self.say("Green")
    self.pickUpFlag(flagGreen)

#3

Thank you very much!


#4

Hi HanSolo, I already tried that but it still doesn’t work. There is a error message for my line 22 of my code as shown in bold below:

Use different colored flags to perform different tasks.
loop:

flagGreen = self.findFlag("green")
flagBlack = self.findFlag("black")
flagViolet = self.findFlag("violet")


if flagBlack:
    pos = flagBlack.pos
    x = pos.x
    y = pos.y
    self.buildXY("fire-trap", x, y)
    self.pickUpFlag(flagBlack)

if flagGreen:
    pos = flagGreen.pos
    x = pos.x
    y = pos.y
    flagGreen = self.buildXY("fence", x, y)
    **self.pickUpFlag(flagGreen)**

if flagViolet:
    pos = flagViolet.pos
    x = pos.x
    y = pos.y
    self.moveXY(x, y)
    self.pickUpFlag(flagViolet)

#5

Try the following:

if flagGreen:
    pos = flagGreen.pos
    x = pos.x
    y = pos.y
    ### This line is wrong ### flagGreen = self.buildXY("fence", x, y)
    self.buildXY("fence", x, y)      #change it to this
    self.pickUpFlag(flagGreen)