guitarplayer616

MAIN schem turtle

Nov 25th, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.14 KB | None | 0 0
  1. --gps addon
  2. --refill addon
  3. --iterator
  4.  
  5. function recordPos(heightPos,widthPos,lengthPos,face)
  6.     local h = fs.open("position","w")
  7.     h.writeLine("heightPos = "..tostring(heightPos))
  8.     h.writeLine("widthPos = "..tostring(widthPos))
  9.     h.writeLine("lengthPos = "..tostring(lengthPos))
  10.     h.writeLine("face = ".."\""..tostring(face).."\"")
  11.     h.close()
  12. end
  13.  
  14. function recordObj(x,y,z)
  15.     local h = fs.open("objective",'w')
  16.     h.writeLine("x = "..tostring(x))
  17.     h.writeLine("y = "..tostring(y))
  18.     h.writeLine("z = "..tostring(z))
  19.     h.close()
  20. end
  21.  
  22. function findNextBlock(x,y,z)
  23.     blockID = getBlockId(x,y,z)
  24.     blockData = getData(x,y,z)
  25.     if blockID then
  26.         slot_lst = slots[blockID][blockData]
  27.         if(slot_lst ~= nil) then
  28.                 if(#slot_lst > 0) then
  29.                     local found=false
  30.                     for i,v in ipairs(slot_lst) do
  31.                         if(turtle.getItemCount(v) > 0) then
  32.                             found=true
  33.                             turtle.select(v)
  34.                             break
  35.                         end
  36.                     end
  37.                     if not found then
  38.                         print("Not enough " .. getBlockName(blockID, blockData) .. ". Please refill...")
  39.                     refill()
  40.                     end
  41.                                 while turtle.getItemCount() == 0 do
  42.                                     refill()
  43.                                 end
  44.                 local doubleCheck = turtle.getItemDetail()
  45.                 if doubleCheck.name ~= "EnderStorage:enderChest" then
  46.                     place()
  47.                 else
  48.                     findNextBlock(x,y,z)  
  49.                 end
  50.             end
  51.             if turtle.getFuelLevel() < 200 then
  52.                 refill()
  53.             end
  54.         end
  55.     end
  56. end
  57.  
  58. function autorun()
  59.     --get the current coords
  60.     --get the iterater/goal block location
  61.     while true do
  62.         shell.run("position")
  63.         shell.run("objective")
  64.         goto(x,y,z)
  65.         findNextBlock(x,y,z)
  66.         checkIfAir()
  67.     end
  68.     shell.run("clr")
  69.     print("finished")
  70. end
Add Comment
Please, Sign In to add comment