Can't use methods with friends


#1

Hey Everyone,

I am playing using Python, on a Windows 10 computer(sorry), using Chrome Navigator.

I am having an issue with the method findByType() when associated with a friend, I get an error, saying tmp38[tmp39] is not a function. Here is my code:
loop:
friends = self.findFriends()
for friend in friends:
yetis = friend.findByType(“yeti”)
yeti = friend.findNearest(yetis)
if yeti:
self.command(friend, “attack”, yeti)

And here is a screen print :

I am having this issue on every level that I can remember of, and it seems to happen everytime I am associating any method with a friend.

I can’t find any topic about this issue. Does someone have already experienced that ?


#2

Please post your code according to the FAQ. It gives an easier understanding of what’s wrong. I will try to help as I am not on this level.


#3

Sorry for the code format, here it is :

loop:
    friends = self.findFriends()
    for friend in friends:
    yetis = friend.findByType("yeti")
    yeti = friend.findNearest(yetis)
    if yeti:
        self.command(friend, "attack", yeti)

#4

It’s ok. Currently on line 6, your indention I think needs to be 1 space over. Also on line 4, You have yeti = friend.findNearestFriend(yetis). Is the (yetis) intentional. And I think on line 3 after for friend in friends and all the other lines need to be indented.


#5

All your friends don’t have findByType. That’s why you’re erroring out.


#6

Friends have limited methods, usually only findNearestEnemy, findfindNearest and findEnemies. See the thang editor for details (e.g. archer and go to the programming.HasAPI section).

But luckily, you can combine them with your methods, e.g.:

enemies = friend.findEnemies()
yeti = self.findByType("yeti")[0]      # select the first (and only) yeti from the list

But to be honest, you don’t really need to do anything with that yeti on this level…


#7

Thanks Everyone, especially Ant, I didn’t know where to look, now I understand what was wrong,.
Thanks for the hint about the Yeti, I had to understand why it wasn’t working so I targeted the first enemy I saw.


#8

You’re welcome @Croks. Glad to try to be helpful.