The Final Kithmaze help

Please tell us more about whats wrong. Also post this with your code. Remember to format your code according to the FAQ.
https://discourse.codecombat.com/faq

1 Like

You are finding the nearestEnemy before even moving once.

When the function is called, that is when the nearestEnemy is assigned to the variable enemy.

So instead of hero.enemy you want to do var enemy = hero.findNearestEnemy();.

2 Likes

the enemy=self.findnearestenemy() dont
work at alllllllllllllllllll!!!:smiling_imp:

1 Like

Are you using correct capitalization and spelling? Provide an instance in which enemy = hero.findNearestEnemy() does not work.

Please do not spam with exclamation marks. It does not help us as the consultant.

You need to capitalize every new word in self.findNearestEnemy

So its find Nearest Enemy() like what I wrote above. Also, if you are using java script, you must use this.findNearestEnemy instead of self

2 Likes

Please do not post the working code. Even though you completed it, somebody could get it. The point of this game is to help kids to learn to code through a game, but not to just give them the code. But good job with the level!

1 Like

im using lua and ive been stuck for a month

@Peter_Fisher I would help but i have no idea how to use lua. it looks complicated. Sorry :confused:

Sorry about that!!!

while True:

hero.moveRight()
hero.moveUp()
hero.moveRight()
hero.moveDown(2)
hero.moveUp()
enemy = hero.findNearestEnemy()
if len(hero,enemy)<60:
    hero.attack(enemy)

@wartxt Please could you say a bit more about what’s happening when you run the code.

1 Like

Yes as @Deadpool198 mentioned, it is hard for us to help you if you have given us little information about what is wrong. Please give info about what is happening when you run your code, any errors when you run your code, and anything else that may be useful to help us help you!:smile:

-@Luke10

I have a question. The only error I run into with my code it the whiletrue function. It works, but I cannot figure out how to run it to where the program runs correctly. I use Python. I read the hints to try to make an understanding, but I don’t get it. It’s very infuriating, considering I went through all of the other levels leading up to this one without any trouble.

Post your code and use the </> button so I can see the error.

while True:
    hero.moveRight()
    hero.moveUp()
    hero.moveRight()
    enemy = hero.findNearestEnemy()
    hero.attack(enemy)
    
    

After this, my hero continues to run into the wall. Do you have any advice on how to stop him from doing this?

Well, you didn’t write any hero.moveDown(), so you will never go down.

I did the down before, and I ran into the wall also.

When I write

while True:
    hero.moveRight()
    hero.moveUp()
    enemy = hero.findNearestEnemy()
    hero.attack(enemy)
    hero.moveDown()
    
    

It walks backwards to the last point.

Well, why don’t you do move: hero.moveDown(2).