while True:
enemy = hero.findNearestEnemy()
item = hero.findNearestItem()
friends = hero.findFriends()
hero.command(friends, "move", item.pos)
idk why this code is not working(not including the enemies) pls help. Tks!
while True:
enemy = hero.findNearestEnemy()
item = hero.findNearestItem()
friends = hero.findFriends()
hero.command(friends, "move", item.pos)
idk why this code is not working(not including the enemies) pls help. Tks!
hero.findFriends()
is an array. Use hero.findNearestFriend
instead.
Maybe she can not use that method ( the more advanced glasses do not have it ) put instead something like this:
for friend in friends:
if friend.type == "peasant":
item = friend.findNearestItem()
if item:
hero.command(friend, "move", item.pos)
Oh yes, that should also work. JavaScript is my language, I’m still working on my Python skills
No problem! Well, I completed the game two times to learn both languages, so to me it is easier to help the Phyton users than it is to you.
Let me know if you have any more problems with this level, ok @anon66968315?
Try ansedras tip. or you can use this: (if your glasses have that ability)
friends = hero.findFriends()
friend = hero.findNearest(friends)
if friend:
hero.command(friend, "attack", hero)
What glasses do you have?
or you dont need to use friends
while True:
enemies = hero.findEnemies()
peasents = hero.findByType("peasents")
for index in range(len(peasents)):
peasent = peasents[index]
enemy = enemies[index]
hero.command(peasent, "move", peasent.findNearestItem().pos)
if enemy and enemy.health > 0:
hero.attack(enemy)
# Maybe use the coins you collected to build some griffin-riders?
# Soldiers are the best for this, or otherwise summon peasents?
You can just use peasents
enchanted lenses, but i have enough gems to buy another. what glasses should i get?
They are good enought, but try to buy twilight glasses when you can. But the glasses won’t be a problem, just use the advice I gave you, ok?
Do you need any more assistance at this level?
byw how do you command the peasents to move to their nearest coins, not my hero’s?
This is how you command peasants to collect their nearest coin.
Tell me if you need any more assistance at this level with this level, all right?
ok. tks for your help!
No problem! Glad I could help you!