A problem with 'blocksBetween' name in the code

14 views
Skip to first unread message

Max Altynnikov

unread,
Sep 5, 2020, 1:32:55 AM9/5/20
to Adventures in Minecraft Forum
Hello!

I'm learning Advetures in Minecraft Second Edition and am stuck on a weird error saying that a name is not defined.

The problem block of code is below:

for blockBetween in blocksBetween[:-1]:
        mc.setBlock(friend.x, friend.y, friend.z, block.AIR.id)
        friend = blockBetween.clone()
        friend.y = c.getHeight(friend.x, friend.z)
        mc.setBlock(friend.x, friend.y, friend.z,
                    block.DIAMOND_BLOCK.id)
        time.sleep(0.25)
    target = friend.clone()
    time.sleep(0.25)

After running the code I get an error message like this:

for blockBetween in blocksBetween[:-1]:
NameError: name 'blocksBetween' is not defined

I was carefully following the book before this error occured and the code worked perfectly before this last cycle :)

Any help is greatly appreciated!

Thnaks!

Martin O'Hanlon

unread,
Sep 13, 2020, 5:59:45 AM9/13/20
to Adventures in Minecraft Forum
Hi,

The error is telling you that the list blocksBetween doesnt exist in your program.

It should have been created on the previous line when you used 

blocksBetween = mcdrawing.getLine(....)

I would check that your spelling of blocksBetween is correct.

Martin 
Reply all
Reply to author
Forward
0 new messages