I am using python.
the code ive used;
while True:
enemy=hero.findNearestEnemy()
hero.attack(enemy)
it always says i ran out of time and that i havent used a loop. I have no idea what it isn’t working
I am using python.
the code ive used;
while True:
enemy=hero.findNearestEnemy()
hero.attack(enemy)
it always says i ran out of time and that i havent used a loop. I have no idea what it isn’t working
Yep, I have the same issue.
The code isn’t working because you aren’t telling it WHEN to work. It knows to find enemies and to attack them, but under what condition should this happen? Are there any enemies?
How about an if statement? If this condition exists, then do something.
while True:
define variable
if this:
then that
You are going to see a TON of this.
`
The code is working: the hero is killing enemies left and right. But the game says that I haven’t used a loop, which I definitelly did.
you haven’t posted your code so it’s kinda hard to see where it is failing. Be sure to use the tick marks so it formats properly with your post.
# if it doesn't look like this in the right hand preview pane then
# it isn't formatted properly.
`
Here’s my code:
while True:
enemy = hero.findNearestEnemy()
hero.attack(enemy)
hero.attack(enemy)
and here’s screenshot:
because it’s in a loop you only need to write the attack line once. Not sure if that is the reason why it’s not registering the code in a loop though. It’s definitely in a while True loop. Someone who knows more than I do about the game source code will have to explain that one.
I have tried what you said but it still didn’t work. Have you solved this level? have you used another solution?
Yes, the code formatted as shown is how I did this level. Going back and looking and running it again, the result is as Denis_Rix said: mine also says that I didn’t use a loop. I guess I didn’t notice that before and I’m not sure why. It also says that I ran out of time. I’m using a fast sword and 2m/sec boots so I’m not sure why about that either. Someone from the game staff is going to have to chime in here.
This was my code:
while True:
enemy = self.findNearestEnemy()
if enemy:
self.attack(enemy)
Sorry about that! There was a bug in a recent patch for this level - it should be fixed now.
while True:
hero.attack(enemy)
hero.attack(enemy)
If your using python, the code above works perfectly!