Why are loops and the attack command not working?


#1

It gives me an error in python that i have to put () instead of loop:


#2

I also have this happening


#3

You already killed the enemy, which is why it says it’s trying to read the position of null.

Edit: Never mind. You are right. for me hero.findEnemies() isn’t working.


#4

As for loops, seems like they got broken somehow)


#5

It’s just a weird way that codecombat is saying, it can’t find an enemy to attack so we are showing you a suggested replacement for it. IDK why they put the ducks in there. XD


#6

Sorry for being off-topic, but why did you delete the ? after “User” in my title? @Chaboi_3000


#7

No(twenty characters)


#8

What do you mean “No”? Weren’t you the one who removed the question mark?


#9

Seriously, I didn’t do it.
BTW I’ve got a painful stomachache today, so I might be off for a while


#10

Okay. oof stomachaches suck


#11

Guys I think I figured out what is going wrong. The hero.findNearestEnemy() would return the nearest person on the Ogres team, not on the enemy’s team (so if you are playing on Ogres team in multiplayer, this would return null)

cuz I tried my code for dueling ground as an ogre and it keeps saying attack has no target, but the same code works when I play as a human.


#12

Use while True: instead of loop: now. loop: was an old CodeCombat-specific syntax construct we put in back when our transpiler required a workaround to make your code not infinitely loop when your loop was empty, but now we can do that inside the normal Python while True: loop, and recently I removed support for loop: (from which we had switched away in our sample code years ago).


Looks like loop has troubles