cecell

Fence Placement

Mar 26th, 2014
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.72 KB | None | 0 0
  1. local tArgs = { ... }
  2. local nCount = tArgs[1]
  3. function restock()
  4.   if turtle.getItemCount(1) < 36 then
  5.     for i=15,2,-1 do
  6.       if turtle.getItemCount(i) > 0 then
  7.         sleep(0.25)
  8.         turtle.select(i)
  9.         turtle.transferTo(1)
  10.         turtle.select(1)
  11.       end
  12.       if turtle.getItemCount(1) > 36 then
  13.         return true
  14.       end
  15.     end
  16.     return false
  17.   else
  18.     return true
  19.     end
  20. end
  21.  
  22. if not nCount then
  23.   print("Usage: place <count>")
  24. return
  25. end
  26.  
  27. if nCount==0 then
  28.     print("Arg 1, <count> must be greater than zero!")
  29. return
  30. end
  31.  
  32. for n=1,nCount do
  33.   restock()
  34.   turtle.select(1)
  35.   if not turtle.detect() then
  36.     turtle.place()
  37.     turtle.back()
  38.   else
  39.     turtle.back()
  40.   end
  41. end
Advertisement
Add Comment
Please, Sign In to add comment