Loop Da Loop statement count error?


#1

Using python for the Loop Da Loop level, I am getting an error and fail. The code is working, but it is failing because it is not under 6 statements (in fact, it is 4 statements). While I am wearing better gear than the level was intended for, this should still pass:

loop:
    gem = self.findNearest(self.findItems())
    if gem:
        self.moveXY(gem.pos.x, gem.pos.y)

#2

Statements are not the same as lines. You actually have 8 statements.


#3

Okay, I get what you mean there, compound vs simple statements, still the semantics are less than clear in this regard.


#4

Also of note, when wearing upgraded boots, the gem check seems to be required, simplified movement loops have you going too fast, eventually you try to pass the laser and die.


#5

I hope you realize that it’s the 3rd topic about the same level today, mentioning basically the same things…


Oh, and btw you can get under 6 statements if you use move instead of moveXY (and use [0] instead of self.findNearest)


#6

Why, when I put this into a loop, is it more than 6 statements?

enemy = self.findEnemies()[0]
if enemy.target:
    self.move(Vector.subtract(Vector(40,40), enemy.target.pos))

Ok - really weird. Just went back to the level and the same code which had failed now reports success. Ugh.
And when I reloaded the level, this went back to failing the 6 statement test. Double ugh.