i keep get cannot read “pos” property error
code-
yDif = hero[0].pos.y - chest[0].pos.y
xDif = hero[0].pos.x - chest[0].pos.x
chest = hero.findItems()[0]
i keep get cannot read “pos” property error
code-
yDif = hero[0].pos.y - chest[0].pos.y
xDif = hero[0].pos.x - chest[0].pos.x
chest = hero.findItems()[0]
The problem is that your putting [0] after chest and hero. Hero is you, there’s only one, so you don’t need to use [0], which would be for finding something in an array, as you’ve done here:
chest = hero.findItems()[0]
But you don’t need to do it again, in fact you can’t. chest is not an array, so you can’t choose the [0]th item in it, because it’s simply one item.
already did that still get same error…
You should keep this line the way it is though, can you please post your code?
here
chest = hero.findItems()[0]
walls = [[0] * 4 for i in range(100)]
steps = []
def direction(n):
x = 0
y = 0
if n == 0:
y += 16
elif n == 1:
x += 16
elif n == 2:
y -= 16
else:
x -= 16
return {"x": hero.pos.x + x, "y": hero.pos.y + y}
while True:
jMod = 0
doNext = True
lastStep = (steps[-1] + 2) % 4
yDif = hero.pos.y - chest.pos.y
xDif = hero.pos.x - chest.pos.x
should i do for chest in chests: #something
No, no need as you already specified the index in the array when defining it at the top.
then, how do i fix this?
I don’t know, maybe @Deadpool198 can help you
help pls i need help @Deadpool198
Maybe your hero can’t see the chest. Perhaps you need to use if?
Maybe try to use twilight glasses to see chest brtter
it working but do u know how to i create a map?