If I take off all glasses, it tells me to equip the twilight glasses.
The bug is that the game doesn’t tell you to equip the twilight glasses if you already have a different pair of glasses equipped. My code is fine, here it is for clarity:
# Calculate the total health of all the ogres.
def sumHealth(enemies):
totalHealth = 0
index = 0
enemies = hero.findEnemies()
while index < len(enemies):
totalHealth += enemies[index].health
index += 1
return totalHealth
# Use the cannon to defeat the ogres.
cannon = hero.findNearest(hero.findFriends())
# The cannon can see through the walls.
enemies = cannon.findEnemies()
# Calculate the sum of the ogres' health.
ogreSummaryHealth = sumHealth(enemies)
hero.say("Use " + ogreSummaryHealth + " grams.")
Actually I can’t test this right now, but I think the game might automatically tell you to equip your best pair of glasses, which for me happens to be the twilight glasses. Could just be a confusing coincidence.
I’m glad I made this thread now. I beat that level on accident using the wrong method and now I’ve learned the correct way.