I am doing the level “Decoy Drill”.
What’s wrong with my code?
# We are field testing a new battle unit: the decoy.
# Build 4 decoys, then report the total to Naria.
# Each decoy costs 25 gold. Use the Quartz Sense Stone
# to know when you have more than 25 gold with self.gold.
# Keep a count of decoys you built as you go along.
# Break out of the loop when you have built 4.
decoysBuilt = 0
loop:
item = self.findNearest(self.findItems())
if self.gold>=25:
self.buildXY("decoy", self.pos.x, self.pos.y)
decoysBuilt+=1
else:
pos=item.pos
x=pos.x
y=pos.y
self.moveXY(x, y)
if decoysBuilt=4:
break
self.say("Done building decoys!")
# Go to Naria and say how many decoys you built.
self.moveXY(14, 36)
self.say("I built "+decoysBuilt+" decoys!")