caucow

collectitems

Dec 28th, 2016 (edited)
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.44 KB | None | 0 0
  1. local function tryMove()
  2.   while turtle.getFuelLevel() == 0 do
  3.     for i = 1, 16 do
  4.       turtle.select(i)
  5.       if turtle.refuel(1) then
  6.         break
  7.       end
  8.     end
  9.     turtle.select(1)
  10.   end
  11. end
  12.  
  13. local function up()
  14.   tryMove()
  15.   while not turtle.up() do
  16.     turtle.digUp()
  17.   end
  18. end
  19.  
  20. local function down()
  21.   tryMove()
  22.   while not turtle.down() do
  23.     turtle.digDown()
  24.   end
  25. end
  26.  
  27. local function forward()
  28.   tryMove()
  29.   while not turtle.forward() do
  30.     turtle.dig()
  31.   end
  32. end
  33.  
  34. local dir = 0
  35. local dx = 0
  36. local dy = 0
  37. local lastx = 0
  38. local lasty = 0
  39. local x = 0
  40. local y = 0
  41. local height = 0
  42.  
  43. local function searchItems()
  44.  
  45. end
  46.  
  47. local function returnHome()
  48.  
  49. end
  50.  
  51. local function invHasItems()
  52.   for i = 1, 16 do
  53.     if turtle.getItemCount() ~= 0 then
  54.       return true
  55.     end
  56.   end
  57.   return false
  58. end
  59.  
  60. local function dropItems()
  61.   local empty = true
  62.   for i = 1, 16 do
  63.     turtle.select(i)
  64.     turtle.drop()
  65.     if turtle.getItemCount() ~= 0 then
  66.       empty = false
  67.     end
  68.   end
  69.   return empty
  70. end
  71.  
  72. local function emptyInventory()
  73.   turtle.turnRight()
  74.   turtle.turnRight()
  75.   local empty = false
  76.   while not empty do
  77.     empty = dropItems()
  78.     if not empty then
  79.       tryMove()
  80.       turtle.up()
  81.       height = height + 1
  82.   end
  83. end
  84.  
  85. local function resumeSearch()
  86.  
  87. end
  88.  
  89. while true do
  90.   while searchItems() do end
  91.   returnHome()
  92.   emptyInventory()
  93.   resumeSearch()
  94. end
Add Comment
Please, Sign In to add comment