Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Level: Sacred Statue and infinite loop of destruction!


Hello everyone! I am a noob so don’t be too hard on me :smile:

Basically I wrote this for Sacred Statue:

def meatgrinder():
    enemy = self.findNearest(self.findEnemies())
    while enemy:
        if self.isReady("cleave"):
            enemy = self.findNearest(self.findEnemies())
            enemy = self.findNearest(self.findEnemies())


    if self.pos.x != 62 and self.pos.y != 67:
        self.moveXY(62, 67)

It was working quite well until half way it stopped and it told me I had failed the level. Before that it was giving me infinite loop errors but working at the same time. :frowning: I know it’s probably not the most elegant code in the world but it was getting the job done! What am I missing?


first of all, your positioning System wont work.

if self.pos.x != 62 and self.pos.y != 67:
        self.moveXY(62, 67)

what if you are standing on (62, 100) ? Your character wont move, because x = 62 is True.

To the Infinite loop. Maybe its because you “real” Code is so short, that he is looping so quick that he thinks thats an Infinite.

Also, why are you calling “meatgrinder()” one time before your loop?


An idea : If there is no enemy, and the position is correct, you’ll do nothing in your loop. So it’ll loop very fast.
Maybe you could try to add
else self.say(“Come on !”)
to wait enemies.