Posted 04 August 2012 - 09:29 PM
I'm trying to make a turtle that digs up until it gets x number of blocks in its first slot. This is the code I have:
When there are less than 20 blocks in slot 1 at the start of the program, it digs, but it keeps going, past 20 blocks. If it starts with 20 or more, it prints "NO!" like it should and doesn't dig. Anyone know why this is happening? I am placing blocks in front of it so it doesn't run off.
local Var= turtle.getItemCount(1)
while Var<20 do
turtle.dig()
end
if Var>=20 then print("NO!")
end
When there are less than 20 blocks in slot 1 at the start of the program, it digs, but it keeps going, past 20 blocks. If it starts with 20 or more, it prints "NO!" like it should and doesn't dig. Anyone know why this is happening? I am placing blocks in front of it so it doesn't run off.