cecell icon

Place10

cecell | PRO | 08/07/14 02:14:53 AM UTC | 0 ⭐ | 447 👁️ | Never ⏰ | []
Lua |

1.1 KB

|

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()
    turtle.back()
    turtle.back()
    turtle.back()
    turtle.back()
    turtle.back()
    turtle.back()
    turtle.back()
    turtle.back()
    turtle.back()
    turtle.back()
  else
    turtle.back()
    turtle.back()
    turtle.back()
    turtle.back()
    turtle.back()
    turtle.back()
    turtle.back()
    turtle.back()
    turtle.back()
    turtle.back()
    turtle.back()
  end
end

Comments