Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sufficientFuel(vector1,vector2,fuel,remainder)
- local distance = math.abs(vector1.x - vector2.x) + math.abs(vector1.y - vector2.y) + math.abs(vector1.z - vector2.z)
- term.clear()
- term.setCursorPos(1,1)
- print("Vector 1: ")
- print("\tX: ",vector1.x)
- print("\tY: ",vector1.y)
- print("\tZ: ",vector1.z)
- print("Vector 1: ")
- print("\tX: ",vector2.x)
- print("\tY: ",vector2.y)
- print("\tZ: ",vector2.z)
- print("Distance: ",distance," + ",remainder," cautionary fuel = ", distance + remainder)
- print("Fuel: ",fuel)
- print("Remainder: ",fuel - (distance + remainder))
- if(fuel <= distance + remainder) then
- return false
- else
- return true
- end
- end
- gpsData = fs.open("GPS_DATA","r")
- local start = vector.new(tonumber(gpsData.readLine()),tonumber(gpsData.readLine()),tonumber(gpsData.readLine()))
- current = vector.new(gps.locate())
- print(sufficientFuel(current,start,turtle.getFuelLevel(),5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement