Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Stillness in Motion Python


#1
loop:
    enemy = self.findNearestEnemy()
    if enemy:
        self.distanceTo(enemy) < 5
        self.attack(enemy)
    if enemy:
        self.distanceTo(enemy) > 5
        self.shield()
    else:
        self.moveXY(40, 34)

Hi.
This is my code for Stillness in motion. I have no clue what is wrong but it’s not working. Sorry if it’s not formatted right but I’m short on time and am in ICT class at school. If someone could lend a hand that’d be great.


#2

The discourse FAQ specifically says “Read Before Posting”. If you didn’t read the FAQ, then you shouldn’t be posting. I will do it for you this time, but don’t post again until you have read the FAQ.

I’ll go through your code line by line:

Line 4: self..distanceTo(enemy) < something returns a boolean that states whether it is true or not. This should be an if-statement.

Line 7: See line 4.


#3

What do you mean by it should be an if-statement. I have if enemy: as my if, but I end up walking over to the head hunters instead.


#4

@ChronistGilver means instead of:

if enemy:
self.distanceTo(enemy) < 5:

It would turn into:

if enemy and self.distanceTo(enemy) < 5:

#5

I finally got it. Thank you so very much.


#6

I still don’t under stand i’m stuck in the whole thing my guy keeps leaving his area


#7

NM Chronist made sence and helped me thank


#8

Have you fixed it? If not please explain the situation more clearly, take your code from the game and post it into the discourse (formatted as stated in the FAQ (search FAQ on the discourse search bar))
and maybe also a screenshot.
Thanks :lion: :lion: :lion:


#9

I think he did, it was good he Solved it


#10

k, (20 charactersAhheyy)


#11

hey id like to ask how to get to the FAQ


#12