Is this possible?
Or did I make that program for nothing :mellow:/>/>
This ability may be added in a future update however.right now it can detect the presence of block.. nothing else
So I can't do something likeThis ability may be added in a future update however.right now it can detect the presence of block.. nothing else
Knope. there is a little way around, but it's mostly useful only for mining
Did you just say what I think you said?nope. there is a little way around, but it's mostly useful only for mining
turtle.dig()
if(turtle.getItemCount(1) == 2)then
turtle.select(1)
print("dirt") --change to name of item in slot 1
turtle.place()
elseif(turtle.getItemCount(2) == 2) then
turtle.select(2)
print("dirt") --change to name of item in slot 2
turtle.place()
elseif(turtle.getItemCount(3) == 2) then
turtle.select(3)
print("dirt") --change to name of item in slot 3
turtle.place()
elseif(turtle.getItemCount(4) == 2) then
turtle.select(4)
print("dirt") --change to name of item in slot 4
turtle.place()
elseif(turtle.getItemCount(5) == 2) then
turtle.select(5)
print("dirt") --change to name of item in slot 5
turtle.place()
elseif(turtle.getItemCount(6) == 2) then
turtle.select(6)
print("dirt") --change to name of item in slot 6
turtle.place()
elseif(turtle.getItemCount(7) == 2) then
turtle.select(7)
print("dirt") --change to name of item in slot 7
turtle.place()
elseif(turtle.getItemCount(8) == 2) then
turtle.select(8)
print("dirt") --change to name of item in slot 8
turtle.place()
else
turtle.select(9)
print("Block Unknown")
turtle.place()
end
Follow the instructions and change "dirt"Spoiler
How do I make it detect what item is in slot 1?
EDIT:
nvm, i made a program that can detect 8 different block types
Code:Follow the instructions and change "dirt"turtle.dig() if(turtle.getItemCount(1) == 2)then turtle.select(1) print("dirt") --change to name of item in slot 1 turtle.place() elseif(turtle.getItemCount(2) == 2) then turtle.select(2) print("dirt") --change to name of item in slot 2 turtle.place() elseif(turtle.getItemCount(3) == 2) then turtle.select(3) print("dirt") --change to name of item in slot 3 turtle.place() elseif(turtle.getItemCount(4) == 2) then turtle.select(4) print("dirt") --change to name of item in slot 4 turtle.place() elseif(turtle.getItemCount(5) == 2) then turtle.select(5) print("dirt") --change to name of item in slot 5 turtle.place() elseif(turtle.getItemCount(6) == 2) then turtle.select(6) print("dirt") --change to name of item in slot 6 turtle.place() elseif(turtle.getItemCount(7) == 2) then turtle.select(7) print("dirt") --change to name of item in slot 7 turtle.place() elseif(turtle.getItemCount(8) == 2) then turtle.select(8) print("dirt") --change to name of item in slot 8 turtle.place() else turtle.select(9) print("Block Unknown") turtle.place() end
-- If bPrintBlock == false or nil, then it will just dig.
-- If bPrintBlock == true, then it will print out the predefined block name (See tBlockType).
-- If bDrop == false or nil, then it will re-place the block after scan.
-- If bDrop == false, then it will drop the digged block, but retain one block for further scanning.
-- Returns true if turtle.dig() was successful, false otherwise.
function dig( bPrintBlock, bDrop )
local bDug = false
local tBlockType = { "dirt", "cobble", "wool" } -- Define the block of the 9 turtle slots here. First entry equals first slot, etc.
-- Ensure there are only 9 defined entries in the table by removing the excess tail.
while #tBlockType > 9 do
table.remove( tBlockType )
end
turtle.select(1) -- Ensures correct pickup-behavior for reliable scanning results.
-- Digs in any case, but only checks blocks and prints them if bPrintBlock is true.
bDug = turtle.dig()
if bDug and bPrintBlock then
for i = 1, #tBlockType do -- Iterate through all defined slots.
if ( turtle.getItemCount(i) > 1 ) then -- Did the current slot count rise above 1?
turtle.select(i)
print( tBlockType[i] )
turtle.place() -- Temporarily re-place a block.
if bDrop then -- If we are in drop mode, we drop the block. If not, we re-place the block.
turtle.drop() -- Drop the whole stack, but then ...
turtle.dig() -- ... reclaim the temporarily placed block to be used for further scanning.
end
print(i)
return bDug -- Stops checking after the first match and returns success or failure of turtle.dig().
end
end
end
return bDug -- Return result of turtle.dig()
end