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

[Help] Type Error on Short-Sighted Burl Level

Hello all,

I am on the level “Short-Sighted Burl.”

I have my code:

Collect coins and run, or else the burl will find you.

This function allows your hero take an item.

def takeItem(item):
hero.moveXY(item.pos.x, item.pos.y)

Write the function “checkTakeRun” with one parameter.

If the item exists, use “takeItem” function to take it.

Go back to the start (green mark), with or without the item.

def checkTakeRun(item):
if item:

Don’t change this code.

while True:
hero.moveXY(16, 56)
coin = hero.findNearestItem()
hero.moveXY(64, 56)
coin = hero.findNearestItem()

but I seem to get an error in the takeItem Function.
the error I get is regarding the “.pos.x” area of the code.

The error reads : Type Error: Cannot read ‘.pos’ of undefined.

Because the code was already there, I didn’t change anything and figured that it should be correct. I went to another level to check that the x coordinate was correctly typed and it seems to be. Can someone help point out what I did wrong?

Thank you,

It’s because you haven’t put a parameter in the brackets of the takeItem function, even though you need one:


1 Like

Thank you so much! That got rid of the error.


This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.