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

Python code error on Thunderhooves

Hi there I got a code error stucking few days on Thunderhooves

My code is like:
while True:
yak = hero.findNearestEnemy()
if yak:
# If yak.pos.y is greater than hero.pos.y
if yak.pos.y > hero.pos.y:
# buildXY a “fence” 10m below the yak.
hero.buildXY(“fence”, yak.pos.x, yak.pos.y - 10)
else:
# buildXY a “fence” 10m above the yak.
hero.buildXY(“fence”, yak.pos.x, yak.pos.y + 10)
pass
else:
# moveXY right 10m towards the oasis.
hero.moveXY(hero.pos.x + 10, hero.pos.y)
pass

I got the python error code:

Line 11: ArgumentError:build’s argument toBuild should have type object, but got string:“fence”. You need a string to build; one of [“bear-trap”]

Any advice for this? Thanks

Hi, welcome to the CodeCombat discourse.
I don’t think you have your hammer equipped. Is that right?
Danny

Thank you Danny you are right I changed hammer instead of sword.

1 Like