Help With Savern Sentry

here is my code :confused:

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

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

Reload all your code. It should be like this:

# Use different colored flags to perform different tasks.

while True:
    flagGreen = hero.findFlag("green")
    flagBlack = hero.findFlag("black")
    
    # If there's a flagGreen...
    
        # Build a "fence" at flagGreen's position.
        
        # Pick up the flag!
        
    # If there's a flagBlack...
    
        # Build a "fire-trap" at flagBlack's position.
        
        # Pick up the flag!
        
    # Move back to the center.
    hero.moveXY(43, 31)
    

After you define flagGreen, check if it exists with an if statement. Inside of that if statement, build a fence at flagGreen’s position x and position y. and pick the flag up Next, check if there is flagBlack. Inside of that if statement, build a fire-trap at its position x and y and pick it up. When you are submitting, if the scouts say there us an ogre coming, use a black flag. if there is a sand yak, use a green flag.

thanks :smiley: that actually really helped

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.