Help in reward and ruination


#1

i have a problem in reward and ruination.all is good , but , the third time my artillery stop shooting.here is my code:

while True:
    enemy = self.findNearest(self.findEnemies())
    if enemy:
        enemyPos = enemy.pos.x + " " + enemy.pos.y
        self.say("Enemy at " + enemyPos)
gem = self.findNearest(self.findItems())
    if gem:
        gemPos = gem.pos.x + " " + gem.pos.y
        self.say("Gem at " + gemPos)

all help will be appreciate.


#2

Could it be the indentation of the gem = line?
You’ll want that line to be part of the code block inside the while loop, not at the same indentation level.


#3

Thank you very much. But in my level gem = self.findNearest(self.findItems()) was aligned.


#4

…and it is not working.