Advertisement
CelticCoder

turtleOneTrip

Nov 12th, 2023 (edited)
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.83 KB | None | 0 0
  1. os.loadAPI("predictPath.lua")
  2. os.loadAPI("turtleToCords.lua")
  3. os.loadAPI("userInput.lua")
  4. os.loadAPI("getTurtleFuel.lua")
  5.  
  6. function getLocation()
  7.     --must be started with pick equipped and modem in first slot
  8.     x = tonumber(userInput.getUserInput("X Cord: "))
  9.     y = tonumber(userInput.getUserInput("Y Cord: "))
  10.     z = tonumber(userInput.getUserInput("Z Cord: "))
  11.     return x, y, z
  12. end
  13.  
  14. function goToCords(x, y, z)
  15.     path = {1}
  16.     predictPath.predict(x, y, z, path)
  17.     predictPath.finalWrite(predictPath.getPath())
  18.     fuelcost = predictPath.getFuelCost()
  19.     if fuelcost > turtle.getFuelLevel() then
  20.         getTurtleFuel.displayFuelInfo()
  21.         print("Fuel Needed: " .. fuelcost)
  22.         print("Fuel too Low to Start, Please Insert Buckets")
  23.         userInput.getUserInput("Type Anything to Refuel")
  24.         shell.run("turtleRefuel.lua")
  25.     end
  26.     if fuelcost > turtle.getFuelLevel() then
  27.         print("Fuel Still too Low to Start, Terminating Program")
  28.     else
  29.         turtleToCords.toCords(predictPath.getDiffX(), predictPath.getDiffY(), predictPath.getDiffZ(), predictPath.getNegX(),    predictPath.getNegY(), predictPath.getNegZ())
  30.     end
  31. end
  32.  
  33. function goToCordsMine(x, y, z)
  34.     path = {1}
  35.     predictPath.predictMine(x, y, z, path)
  36.     predictPath.finalWrite(predictPath.getPath())
  37.     fuelcost = predictPath.getFuelCost()
  38.     if fuelcost > turtle.getFuelLevel() then
  39.         getTurtleFuel.displayFuelInfo()
  40.         print("Fuel Needed: " .. fuelcost)
  41.         print("Fuel too Low to Start, Please Insert Buckets")
  42.         userInput.getUserInput("Type Anything to Refuel")
  43.         shell.run("turtleRefuel.lua")
  44.     end
  45.     if fuelcost > turtle.getFuelLevel() then
  46.         print("Fuel Still too Low to Start, Terminating Program")
  47.     else
  48.         turtleToCords.toCordsMine(predictPath.getDiffX(), predictPath.getDiffY(), predictPath.getDiffZ(), predictPath.getNegX(),    predictPath.getNegY(), predictPath.getNegZ())
  49.     end
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement