Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Cloudrip treasure help - Python

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!

2 Likes

hero.findFriends() is an array. Use hero.findNearestFriend instead.

2 Likes

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)
2 Likes

Oh yes, that should also work. JavaScript is my language, I’m still working on my Python skills :slight_smile:

2 Likes

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.

2 Likes

Let me know if you have any more problems with this level, ok @anon66968315?

2 Likes

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)
1 Like

What glasses do you have?

2 Likes

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

1 Like

enchanted lenses, but i have enough gems to buy another. what glasses should i get?

1 Like

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?

1 Like

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!

1 Like

No problem! Glad I could help you! :smiley: