cecell icon

Fence Placement

cecell | PRO | 03/26/14 09:22:25 PM UTC | 0 ⭐ | 330 👁️ | Never ⏰ | []
Lua |

720 B

|

None

|

0 👍

/

0 👎

local tArgs = { ... }
local nCount = tArgs[1]
function restock()
  if turtle.getItemCount(1) < 36 then
    for i=15,2,-1 do
      if turtle.getItemCount(i) > 0 then
        sleep(0.25)
        turtle.select(i)
        turtle.transferTo(1)
        turtle.select(1)
      end
      if turtle.getItemCount(1) > 36 then
        return true
      end
    end
    return false
  else
    return true
    end
end
 
if not nCount then
  print("Usage: place <count>")
return
end
 
if nCount==0 then
    print("Arg 1, <count> must be greater than zero!")
return
end
 
for n=1,nCount do
  restock()
  turtle.select(1)
  if not turtle.detect() then
    turtle.place()
    turtle.back()
  else
    turtle.back()
  end
end

Comments