Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Level decoy drill



# 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
# Keep a count of decoys you built as you go along.
# Break out of the loop when you have built 4.
decoysBuilt = 0
    item = self.findNearest(self.findItems())
    if < 25 :
        self.moveXY(item.pos.x, item.pos.y)
        self.buildXY("decoy", self.pos.x - 2, self.pos.y -2)
        decoysBuilt = decoysBuilt+1
        if decoysBuilt < 4 :
self.say("Done building decoys!")
# Go to Naria and say how many decoys you built.
self.moveXY(14, 36)

Yes, and what is the problem you are seeing?

I’m guessing its finishing after just building one decoy? Because decoysBuild < 4? But hard to tell from the ??? description.


Help us help you…

What happens when you run this code that you thing shouldn’t happen? This makes it eaiser for us to figure out what is wrong.

One I can see without even thinking is that you never tell Naria how many you built.

With a little thinking I see that you have ‘<’ when you should have ‘>=’ …

Since I don’t know for sure what is going wrong, I’ll not look any harder. :wink:

1 Like

thx guys fixed problem