Advertisement
lucifersamfr

sideWalkFiller

Mar 24th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.31 KB | None | 0 0
  1. local fillInt = false
  2. local fillExt = false
  3. local squareSize = 7
  4. local pause = 60
  5.  
  6. function compactInv()  
  7.   for i = 1,16 do
  8.     if turtle.getItemCount(i) > 0 and turtle.getItemCount(i) < 64 then
  9.       turtle.select(i)
  10.       for j = i+1,16 do
  11.         if turtle.compareTo(j) then
  12.           turtle.select(j)
  13.           turtle.transferTo(i)
  14.           turtle.select(i)
  15.         end
  16.       end
  17.     end
  18.   end
  19.      
  20.   for i = 1,16 do
  21.     if turtle.getItemCount(i) > 0 then
  22.       for j = 1,i do
  23.         if turtle.getItemCount(j) == 0 then
  24.           turtle.select(i)
  25.           turtle.transferTo(j)
  26.           break
  27.         end
  28.       end
  29.     end
  30.   end
  31. end
  32.  
  33. function checkItems()
  34.   if ( turtle.getItemCount(1) < 2 ) then
  35.     compactInv()
  36.     turtle.select(1)
  37.   end
  38. end
  39.  
  40. function fill(size, interior, exterior)
  41.   for side = 1, 4 do
  42.     for i=1, (size-1) do
  43.       turtle.move("front")
  44.       checkItems()
  45.      
  46.       if interior then
  47.         turtle.turnRight()
  48.         if not turtle.detect() then
  49.           turtle.place()
  50.         end
  51.         turtle.turnLeft()
  52.       end
  53.      
  54.       if exterior then
  55.         turtle.turnLeft()
  56.         if not turtle.detect() then
  57.           turtle.place()
  58.         end
  59.         turtle.turnRight()
  60.       end    
  61.     end
  62.     turtle.turnRight()
  63.   end
  64. end
  65.  
  66. while true do
  67.   turtle.select(1)
  68.   fill(squareSize, fillInt, fillExt)
  69.   sleep(pause)
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement