Help me with Woodland Cubbies ( and other questions too)

Please help me I really need help with Woodland Cubbies!
If you can help and you post or like anything then thank you!

Can you post your code as it says in this:

Lydia

3 Likes

Also like please show your code we don’t even know your progress
~ Orb

3 Likes

We can’t help you if you don’t show us what you need help with.

2 Likes

Sorry it took me awhile to get back I am using python to start out with and
I will move to javascript etc. my code is:
hero.moveXY(19, 33)
enemy = hero.findNearestEnemy()

if enemy:
hero.attack(enemy)
hero.attack(enemy)

hero.moveXY(49, 51)
enemy2 = hero.findNearestEnemy()
if enemy2:

hero.attack(enemy2)
hero.attack(enemy2)

hero.moveXY(58, 14)
enemy3 = hero.findNearestEnemy()

if enemy3:

hero.attack(enemy3)
hero.attack(enemy3)

Can you please format all of your code as it is described below so we will be able to help you solve the level?

Andrei

1 Like
hero.moveXY(19, 33)
enemy = hero.findNearestEnemy()
if enemy:
    hero.attack(enemy)
    hero.attack(enemy)
hero.moveXY(49, 51)
enemy2 = hero.findNearestEnemy()
if enemy2:
    hero.attack(enemy2)
    hero.attack(enemy2)
hero.moveXY(58, 14)
enemy3 = hero.findNearestEnemy()
if enemy3:
    hero.attack(enemy3)
    hero.attack(enemy3)

@AnSeDra
I formatted his code
~ Orb

1 Like

Hey… I don’t think you have any mistakes man
~ Orb

What is the link for this level?
Lydia

https://codecombat.com/play/level/woodland-cubbies?
~ Orb

1 Like

Hmm… try putting

pass

at the end of each “if” statement.
Lydia

It doesn’t help, pass acts as a placeholder for code.
For example, I want to test this code:

if hero.canCast("summon-undead"):
    
while True:
    enemy = hero.findNearestEnemy()
    if enemy and hero.canCast("drain-life", enemy):
        hero.cast("drain-life", enemy)

If I just wanted to run the while True part, and I want to leave the if hero.canCast("summon-undead") part empty, so I leave it blank, like in the code. If I do so, an error message will appear: Empty if statement. Put 4 spaces in front of statements inside the if statement. So, pass was invented to act as a placeholder, the only use for it is to avoid error messages that might stop the code running when put in empty statements, basically, it makes life a bit easier for developers, but other than that, it has no effect on the actual code.
~ Orb
Oh yeah, @Gabriel_Knight you’re code is probably right.

1 Like

the code works for me

Yes, Gabriel_Knight’s code is right. I just thought it might be a helpful hint?
Lydia

Maybe @Gabriel_Knight just formatted his code incorrectly?
Lydia

1 Like

Yes I agree, indentation is very important in Python
@Gabriel_Knight
~ Orb

3 Likes

This is why it is so important to anyone who need help to format their code, so we can see if they have any identation errors.

Andrei

1 Like

@Gabriel_Knight Are you there?

Lydia

1 Like

yeah I am its just need to hop off at three sorry.

2 Likes