Advertisement
CelticCoder

turtleGeoScanMine

Dec 1st, 2024 (edited)
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. os.loadAPI("turtleManualOneTrip.lua")
  2. --start with pick in left and geoscanner in right of turtle, and modem in first slot
  3.  
  4. function scan()
  5.     scanner = peripheral.wrap("right")
  6.     if scanner.cost(15) > scanner.getFuelLevel() then
  7.         print("Not Enough Fuel")
  8.         print("Cost: " .. scanner.cost(15))
  9.         print("Fuel Level: " .. scanner.getFuelLevel() .. "/" .. scanner.getMaxFuelLevel())
  10.         os.exit(1)
  11.     end
  12.  
  13.     turtle.equipRight()
  14.     rednet.open("right")
  15.     cx, cy, cz = gps.locate()
  16.     if cx == nil and cy == nil and cz == nil then
  17.         print("GPS Error")
  18.         os.exit(1)
  19.     end
  20.     turtle.equipRight()
  21.  
  22.     if not item and choice == 2 then
  23.         print("No Name Inputted")
  24.         os.exit(1)
  25.     end
  26.  
  27.     return scanner.scan(15)
  28. end
  29.  
  30. function geoMineItem(item)
  31.     blocks = scan()
  32.     if blocks ~= nil then
  33.         for _, block in pairs(blocks) do
  34.             if block.name == item then
  35.                 x = cx + block.x
  36.                 y = cy + (block.y + 1)
  37.                 z = cz + block.z
  38.                 turtleManualOneTrip.goToCordsMine(x, y, z)
  39.             end
  40.         end
  41.         turtleManualOneTrip.goToCordsMine(cx, cy, cz)
  42.     else
  43.         print("Couldnt Scan")
  44.     end
  45. end
  46.  
  47. function geoMineList(itemlist)
  48.     if itemlist ~= nil then
  49.         blocks = scan()
  50.     else
  51.         print("Itemlist no found")
  52.         os.exit(1)
  53.     end
  54.     if blocks ~= nil and itemlist ~= nil then
  55.         for _, block in pairs(blocks) do
  56.             for _, item in pairs(itemlist) do
  57.                 if block.name == item then
  58.                     x = cx + block.x
  59.                     y = cy + (block.y + 1)
  60.                     z = cz + block.z
  61.                     turtleManualOneTrip.goToCordsMine(x, y, z)
  62.                 end
  63.             end
  64.         end
  65.         turtleManualOneTrip.goToCordsMine(cx, cy, cz)
  66.     elseif blocks == nil  then
  67.         print("Couldnt Scan")
  68.     elseif itemlist == nil then
  69.         print("Itemlist no found")
  70.     end
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement