while hero.time < 20:
coin = hero.findNearestItem()
distance = hero.distanceTo(coin)
if coin and distance < 65:
hero.move(coin.pos)
if hero.gold > 30:
break
# Collect coins
# Retreat behind the fence
self.move({"x": 16, "y": 35})
hero.buildXY("fence", 17, 35)
Really struggling on this level. Trying to write some code just to complete it but can’t get past an object/string error on line 18 of my code (fence part)? Help!
You’re very close, all you need to do is change move to moveXY at the end when it tells you to retreat, It’s because when move isn’t looped it tends to only go a a tiny bit and then it stops.
Your coordinates won’t work, or at least they didn’t for me, but just play around with different coordinates and you’ll get it.
Your code is working fine, however as Deadpool198 says, your coordinates do not work. I did not receive any errors so this may be an equipment issue. Please post a screen shot of your equipment.
The error message is correct and telling you what’s wrong. You’re using the wrong hammer. The hammer you’re using does not have the ability to build a fence.