Advertisement
CelticCoder

manualTurtleGeoScanMine

Aug 8th, 2024 (edited)
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.47 KB | None | 0 0
  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 getSearchItem()
  5.     print("Please Insert Item to Mine in Second Slot")
  6.     print("Then Press Enter")
  7.     read()
  8.     desireditem = turtle.getItemDetail(2)
  9.     return desireditem.name
  10. end
  11.  
  12. scanner = peripheral.wrap("right")
  13. if scanner.cost(15) > scanner.getFuelLevel() then
  14.     print("Not Enough Fuel")
  15.     print("Cost: " .. scanner.cost(15))
  16.     print("Fuel Level: " .. scanner.getFuelLevel() .. "/" .. scanner.getMaxFuelLevel())
  17.     os.exit(1)
  18. end
  19.  
  20. turtle.equipRight()
  21. rednet.open("right")
  22. cx, cy, cz = gps.locate()
  23. if cx == nil and cy == nil and cz == nil then
  24.     print("GPS Error")
  25.     os.exit(1)
  26. end
  27. turtle.equipRight()
  28.  
  29. print("Item or Name? (1 or 2)")
  30. choice = tonumber(read())
  31. if choice ~= nil and choice == 1 then
  32.     item = getSearchItem()
  33. elseif choice ~= nil and choice == 2 then
  34.     print("Please input item in game name (with library included)")
  35.     item = read()
  36. end
  37.  
  38. if not item and choice == 1 then
  39.     print("No Item Inserted")
  40.     os.exit(1)
  41. elseif not item and choice == 2 then
  42.     print("No Name Inputted")
  43.     os.exit(1)
  44. end
  45.  
  46. blocks = scanner.scan(15)
  47.  
  48.  
  49. if blocks ~= nil then
  50.     for _, block in pairs(blocks) do
  51.         if block.name == item then
  52.             x = cx + block.x
  53.             y = cy + (block.y + 1)
  54.             z = cz + block.z
  55.             turtleManualOneTrip.goToCordsMine(x, y, z)
  56.         end
  57.     end
  58.     turtleManualOneTrip.goToCordsMine(cx, cy, cz)
  59. else
  60.     print("Couldnt Scan")
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement