Advertisement
montana_1

sufficientFuel

Oct 25th, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  1. function sufficientFuel(vector1,vector2,fuel,remainder)
  2.    
  3.     local distance = math.abs(vector1.x - vector2.x) + math.abs(vector1.y - vector2.y) + math.abs(vector1.z - vector2.z)
  4.     term.clear()
  5.     term.setCursorPos(1,1)
  6.     print("Vector 1: ")
  7.     print("\tX: ",vector1.x)
  8.         print("\tY: ",vector1.y)
  9.         print("\tZ: ",vector1.z)
  10.     print("Vector 1: ")
  11.     print("\tX: ",vector2.x)
  12.         print("\tY: ",vector2.y)
  13.         print("\tZ: ",vector2.z)
  14.     print("Distance: ",distance," + ",remainder," cautionary fuel = ", distance + remainder)
  15.     print("Fuel: ",fuel)
  16.     print("Remainder: ",fuel - (distance + remainder))
  17.     if(fuel <= distance + remainder) then
  18.         return false
  19.     else
  20.         return true
  21.     end
  22. end
  23.  
  24. gpsData = fs.open("GPS_DATA","r")
  25. local start = vector.new(tonumber(gpsData.readLine()),tonumber(gpsData.readLine()),tonumber(gpsData.readLine()))
  26.  
  27. current = vector.new(gps.locate())
  28.  
  29. print(sufficientFuel(current,start,turtle.getFuelLevel(),5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement