visiongaming43

startup

May 21st, 2022
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. -- This file uses the functions from Methods
  2. require("Methods")
  3. resetPos()
  4. -- Calculating Fuel Level and Fuel Needed ( Also caching file into a list )
  5. local file = fs.open("Settings", "r")
  6. local list = {}
  7. local line = file.readLine()
  8. while line do
  9. list[#list+1] = line
  10. line = file.readLine()
  11. end
  12. file.close()
  13.  
  14. local length = list[4]
  15. local width = list[5]
  16.  
  17. local fuelLevel = turtle.getFuelLevel()
  18. local fuelNeeded = (length * width) + (length + width)
  19.  
  20. if(fuelLevel > fuelNeeded) then
  21. local direction = list[6]
  22. local nextTurn
  23. local lastTurn
  24. if (direction == "LEFT") then
  25. nextTurn = turtle.turnLeft
  26. lastTurn = turtle.turnRight
  27. else
  28. nextTurn = turtle.turnRight
  29. lastTurn = turtle.turnLeft
  30. end
  31.  
  32. turtle.forward()
  33. while(length > 0) do
  34. nextTurn()
  35. getCrop()
  36. while (width > 0) do
  37. turtle.forward()
  38. getCrop()
  39. width = width - 1
  40. end
  41. lastTurn()
  42. length = length - 1
  43. width = list[5]
  44. turtle.forward()
  45.  
  46. tempTurn = nextTurn
  47. nextTurn = lastTurn
  48. lastTurn = tempTurn
  49. end
  50. resetPos()
  51. -- Starts a timer that lasts 500 seconds. After the timer ends, the turtle reboots, and therefore repeats the program (Assuming the program is named 'startup' and has fuel)
  52. local timerID = os.startTimer(500)
  53. local event, id
  54. repeat
  55. event, id = os.pullEvent("timer")
  56. until id == timerID
  57. os.reboot()
  58. end
  59.  
  60. -- If the turtle doesn't have fuel, it will display this message telling the user to feed it or fuck off
  61. print("NOT ENOUGH FUEL BRO")
Add Comment
Please, Sign In to add comment