During Vital Powers, I’m getting an error on line 50: “Line 50: Undefined label ‘undefined’”. The problem is, there is not line 50. Is it my code:
# This level shows how to define your own functions.
# The code inside a function is not executed immediately. It's saved for later.
# This function has your hero collect the nearest coin.
def pickUpNearestCoin():
totalGold = 0
items = self.findItems()
nearestCoin = self.findNearest(items)
if nearestCoin:
self.move(nearestCoin.pos)
totalGold += nearestCoin.value
if totalGold >= 125:
break
# This function has your hero summon a soldier.
def summonSoldier():
# Fill in code here to summon a soldier if you have enough gold.
if self.gold >= 20:
self.summon("soldier")
# This function commands your soldiers to attack their nearest enemy.
def commandSoldiers():
for soldier in self.findFriends():
enemy = soldier.findNearestEnemy()
if enemy:
self.command(soldier, "attack", enemy)
self.toggleFlowers(False)
loop:
# In your loop, you can "call" the functions defined above.
# The following line causes the code inside the "pickUpNearestCoin" function to be executed
pickUpNearestCoin()
summonSoldier()
commandSoldiers()
loop:
enemy = self.findNearest(self.findEnemies())
if enemy:
if self.canCast("chain-lightning"):
self.cast("chain-lightning")
elif self.isReady("bash"):
self.shield()
self.bash(enemy)
else:
self.shield()
self.attack(enemy)
or something else: