Here is the problem. Try to put what the convert function returns in a variabile pos then moveXY to pos.x and pos.y.
And if there is no enemy, then find the nearest item and moveXY to its position.
Do you need any more assistance at this level?
here’s my new code. it says that i and j are undefined.
for i in range(len(powerMap)):
for j in range(len(powerMap[i])):
pointValue = powerMap[i][j]
if i and j and pointValue and pointValue > 0:
convert(i, j)
hero.moveXY(i.pos.x, j.pos.y)
hero.say("VENI")
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
coin = hero.findNearestItem()
if coin:
hero.moveXY(coin.pos.x, coin.pos.y)
spell = "VENI"
wizard = hero.findNearest(hero.findFriends())
powerMap = wizard.powerMap
def convert(row, col):
return {'x': 16 + col * 12, 'y': 16 + row * 12}
for i in range(len(powerMap)):
for j in range(len(powerMap[i])):
pointValue = powerMap[i][j]
if i and j and pointValue and pointValue > 0:
posi = convert(i, j)
hero.moveXY(posi.pos)
hero.say("VENI")
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
coin = hero.findNearestItem()
if coin:
hero.moveXY(coin.pos.x, coin.pos.y)