qwerty
October 9, 2021, 7:57pm
1
my code:
# You'll need good strategy to win this one!
# Your clone will have the same equipment you have!
# But, they're not very skilled at using special powers.
while True:
enemy = hero.findNearestEnemy()
if enemy.distance < 10:
hero.attack(enemy)
if hero.health < hero.maxHealth/2:
hero.jumpTo(36,53)
this is where the error is:
if enemy.distance < 10:
thanks moon!
Anonym
October 9, 2021, 7:58pm
2
Well, firstly try rewriting this line of code,
qwerty
October 9, 2021, 8:01pm
5
its ok we all have to sleep.
Uhhhh, it’s supposed to be hero.distanceTo(enemy)
… I think you should have already learned this in the forest.
1 Like
qwerty:
hero.jumpTo(36,53)
And the argument needs to be a position, so like:
Javascript:
{x: 36, y: 53};
Python:
{"x": 36, "y": 53}
qwerty
October 9, 2021, 8:06pm
8
oh ok i’ll try that
i haven’t played in a while so i forgot
Bruh, he isn’t even in the Mountains yet, how would he know about vectors???
idk but u can do,
while loops, for loops and if/else and while True loops with no programiticon
True, but you wouldn’t be able to see how if you didn’t remember.
Well technically it’s not off-topic, but thats good idea.
qwerty:
if enemy.distance < 10:
The problem is that you haven’t checked if the enemy exists.
And what moonwatcher said.
you still need to do enemy && hero.distanceTo(enemy)
or enemy and hero.distanceTo(enemy)
to check if the enemy exists or it will throw an error.
system
Closed
October 10, 2021, 10:17am
19
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.