Hi, please create a new topic and don’t revive super old ones
I need help with Valley of a Thousand Rockswhile True:
item = hero.findNearestItem()
if hero.health < hero.health / 3:
hero.say(“heal me”)
elif item.pos.y > hero.pos.y:
hero.moveXY(hero.pos.x, hero.pos.y + 8)
elif item.pos.x > hero.pos.x:
hero.moveXY(hero.pos.x + 8, hero.pos.y)
Correction:
while True:
item = hero.findNearestItem()
if hero.health < hero.health / 3:
hero.say(“heal me”)
elif item.pos.y > hero.pos.y:
hero.moveXY(hero.pos.x, hero.pos.y + 8)
elif item.pos.x > hero.pos.x:
hero.moveXY(hero.pos.x + 8, hero.pos.y)
hello, welcome
but please do not revive dead topics, if u need help, just make a new one
And also format your code using the code button please :) you can find everything in the “welcome to discourse” at the top of the page
Hi, @Dhanya_DESAI @Rocco_Nasca , welcome to the codecombat discourse!
If you need help click this to create new topic!
(@)Rocco_Nasca posted more than 4 months ago .-.

it keeps saying “cannot read property of ‘pos’ null.”
What level? :] and can you please post your full code?
The level is the valley of a thousand rocks.
while True:
item = hero.findNearestItem()
if hero.health < hero.health / 3:
hero.say("Heal me.")
elif item.pos.y > hero.pos.y:
hero.moveXY(hero.pos.x,hero.pos.y + 8)
elif item.pos.x > hero.pos.y:
hero.moveXY(hero.pos.x + 8,hero.pos.y)
Oh interesting I haven’t done this level before, give me a few minutes while I complete it .-.
Well, I actually didn’t have to complete it to see your errors:
if hero.health < hero.health / 3
hero.MAXhealth / 3 (hero.maxHealth / 3)
if item.pos.x > hero.pos.y
hero.XPOSITION (hero.pos.x)
oh also, a good practice is to add spaces after commas
it still does not work
while True:
item = hero.findNearestItem()
if hero.maxhealth < hero.maxHealth / 3:
hero.say("Heal me.")
elif item.pos.y > hero.pos.y:
hero.moveXY(hero.pos.x, hero.pos.y + 8)
elif item.pos.x > hero.pos.x:
hero.moveXY(hero.pos.x + 8, hero.pos.y)
if hero.maxHealth < hero.maxHealth / 3
I only mean for you to change the 2nd property, the first should still be normal health
Mmm, because its a CS LEVEL
Well, I do have a class account and I’ve never done it, soooo
like this?
while True:
item = hero.findNearestItem()
if hero.health < hero.maxHealth / 3:
hero.say("Heal me.")
elif item.pos.y > hero.pos.y:
hero.moveXY(hero.pos.x, hero.pos.y + 8)
elif item.pos.x > hero.pos.x:
hero.moveXY(hero.pos.x + 8, hero.pos.y)
it still says the same error
There might not be an item at that particular moment. You should check if there is one before checking where it is in relation to your hero.