Advertisement
JadenR

Untitled

Jul 13th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. function ReturnFileData(filepath)
  2. local file = fs.open(filepath, "r")
  3. local filedata = {}
  4. local line = file.readLine()
  5. repeat
  6. table.insert(filedata, line)
  7. line = file.readLine()
  8. until line == nil
  9. file.close()
  10. return filedata
  11. end
  12.  
  13. function dd()
  14. if turtle.detectDown() then
  15. turtle.digDown()
  16. end
  17. end
  18.  
  19. function pd()
  20. turtle.placeDown()
  21. end
  22.  
  23. function mf(distance)
  24. if distance == nil then distance = 1 end
  25. for i = 1, distance do
  26. if turtle.detect() then
  27. turtle.dig()
  28. turtle.forward()
  29. else
  30. turtle.forward()
  31. end
  32. end
  33. end
  34.  
  35. function tl()
  36. turtle.turnLeft()
  37. end
  38.  
  39. function tr()
  40. turtle.turnRight()
  41. end
  42.  
  43. function Path(distance)
  44. turtle.select(3)
  45. for i = 1, distance do
  46. mf()
  47. dd()
  48. pd()
  49. end
  50. end
  51.  
  52. function MakePath()
  53. Path(9) --Initial move forward(1)
  54. tr()
  55. Path(4) --Move right forward (2)
  56. tr()
  57. Path(5)--Move down forward (3)
  58. tl()
  59. Path(4)
  60. tl()
  61. Path(4)
  62. tr()
  63. Path(4)
  64. tr()
  65. Path(8)
  66. tr()
  67. Path(11)
  68. mf()
  69. tr()
  70. end
  71.  
  72. function SetUp()
  73. turtle.refuel()
  74. dd()
  75. turtle.select(2)
  76. pd()
  77. MakePath()
  78. end
  79.  
  80. function CheckSetUp()
  81. if not fs.exists("Config.lua") then
  82. local file = fs.open("Config.lua", "w")
  83. file.close()
  84. end
  85. local FileData = ReturnFileData("Config.lua")
  86. if #FileData == 0 then
  87. print("Never Set up Before!")
  88. print("Setting up...")
  89. local file = fs.open("Config.lua", "a")
  90. file.writeLine("Setup = true")
  91. file.close()
  92. SetUp()
  93. else
  94. print(FileData[1])
  95. print(#FileData)
  96. print("Set up before")
  97. end
  98. end
  99.  
  100. CheckSetUp()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement