Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Level: Forest Fire Dancing

#1

Hello all,

I’m a little stuck on this level and seeking some help. This is my code with comments cut out:

while True:

evilstone = hero.findNearestItem()
if evilstone:
pos = evilstone.pos
if pos.x == 34:
hero.moveXY(46,22)

else:
hero.moveXY(34,22)

else:
hero.moveXY(40,22)

For some reason my character just stops after about 11 seconds and stands in the middle, getting hit with a fireball. Everything is running great up to that point.

I also tried changing the nested else statement to an elif pos.x == 46 but this did not help.

Any help would be greatly appreciated.

1 Like
#2

I fixed it. Disregard.

1 Like
#3

I also have a similar problem, my hero would be dodging the fireballs and then after he dodges one certain fireball, the fireballs would stop, then, my hero would die. Here is my code:

while True:
    evilstone = hero.findNearestItem()
    if evilstone:
        pos = evilstone.pos
        if pos.x == 34:  
            hero.moveXY(46, 22)
            
            pass
        else:
            hero.moveXY(34, 23)
            pass
    else:
        hero.moveXY(40, 22)
        pass

#4

I can’t find a problem or anything wrong with my code.

#5

Change 23 to 22 and you’ll win

#6

while True:
evilstone = hero.findNearestItem()
if evilstone:
pos = evilstone.pos
if pos.x == 34: # == means “is equal to”
# If the evilstone is on the left, go to the right side.
hero.moveXY(46, 22)
pass
else:
# If the evilstone is on the right, go to the left side.
hero.moveXY(34, 23)
pass
else:
# If there’s no evilstone, go to the middle.
hero.moveXY(40, 23)
pass

#7

Please learn to post your code properly. It’s really easy and only requires a very small amount of effort.

To post your code from the game, use the </> button or it won’t format properly. When you click the </> button, the following will appear:

Please paste ALL of your code inside the triple back tick marks.

``` <— Triple back tick marks.

Paste ALL of your code in here.

``` <— Triple back tick marks.

There are many people here willing and able to help. If you use the </> button correctly, then ALL of your code should look like this:

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)
    else:
        hero.say("My code is formatted properly")

If ALL of your code isn’t formatted like the code above, then you’re doing it wrong and we can’t see the structure of the code to troubleshoot whether or not that is the issue. Use the </> button and help us help you. This works when sending a private message as well.

Thank you.

#8

Mod edit: [Please don’t post successful solutions.]