My hero doesnt even walk around to collect gold or summon troops
This is my new code on line 2 it says reference error summontypes is not defined
This is telling you that you are referencing (reference error) a variable that isn’t defined (is not defined). The specific variable you are referencing which is undefined is: summonTypes.
type=summonTypes[len(self.built) % len(summonTypes)]
You need to define summonTypes before manipulating it.
ok i must have forgot to do so
I fixed my code here it is
def summonTypes():
type=summonTypes[len(self.built) % len(summonTypes)]
def summonTroops():
if self.gold >= self.costOf('soldier'):
self.summon('soldier')
def commandTroops():
friends=self.findFriends()
for friend in friends != 'palisade':
enemies=self.findEnemies()
enemy=soldier.findNearestEnemy()
self.command(friend, "attack", enemy)
def collectCoins():
coin=self.findNearest(self.findItems())
self.move(coin.pos)
loop:
summonTypes()
summonTroops()
commandTroops()
collectCoins()
My troops dont even attack my hero is summoning them but they dont attack
nvm i beat it i just collected 300 gold