This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
AndyMcB1's profile picture

How would I do this..

Started by AndyMcB1, 12 December 2012 - 10:20 PM
AndyMcB1 #1
Posted 12 December 2012 - 11:20 PM

local args = { ... }
if #args >= 1 then
  local slot = tonumber(args[1])
  if slot and slot >= 1 and slot <= 16 then
    turtle.select(slot)
  end
end
function prevBlockSlot(curSlot)
  for slot=curSlot,2,-1 do
    turtle.select(slot)
    if turtle.compareTo(1) then
	  return slot
    end
  end
end

while true do
  if not turtle.place() then
    break
  end
  if not turtle.dig() then
    break
  end
end

I'm wanting the program to get the block in slot 1 then scan to see if there's other slots with the same type of block, and remember

Then I want it to break and place blocks, when the block in the slot changes go to the next slot with the inital block.

..help? I'm no programmer..
KaoS #2
Posted 13 December 2012 - 02:49 AM
this should work


local tArgs={...}
local curS=tonumber(tArgs[1]) or 1
if  turtle.getItemCount(curS)>0 then
  for i=1,16 do
	turtle.select(i)
	if i~=curS then
	  while turtle.compareTo(curS) and turtle.place() and turtle.dig() do end
	end
  end
  turtle.select(curS)
  while turtle.getItemCount(curS)>1 and turtle.place() and turtle.dig() do end
end

EDIT: forgot to mention, it will leave one of the item in the primary slot or it may get confused