Hi all, i 'm getting an error telling me that something is undefined but i thought i had defined it.
here it is.
CodeCombat - Coding games to learn Python and JavaScript? Two Flowers link.
# If the peasant is damaged, the flowers will shrink!
def summonSoldiers():
if hero.gold >= hero.costOf("soldier"):
hero.summon("soldier")
# Define the function: commandSoldiers
def commandSoldiers():
for soldier in hero.findFriends():
enemy = hero.findNearestEnemy()
if soldier.type == "soldier":
peasant = hero.findByType("peasant")[0]
if enemy:
hero.command(soldier, "defend", peasant.pos.x, peasant.pos.y)
# Define the function: pickUpNearestCoin
def pickUpNearestCoin():
items = hero.findItems()
nearestCoin = hero.findNearestItem()
if nearestCoin:
hero.move(nearestCoin.pos)
while True:
summonSoldiers()
commandSoldiers()
pickUpNearestCoin()
arent i defining peasant by with this? >>> peasant = hero.findByType("peasant")[0]