Parmacoy

ScholarlyOS

Mar 7th, 2021 (edited)
614
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if not(fs.exists("libraryEvolved")) then
  2.     shell.run("pastebin","get","vBk3y8Np","libraryEvolved")
  3. end
  4. os.loadAPI("libraryEvolved")
  5.  
  6. gui.setTitle("ScholarlyOS")
  7. gui.setPadding(" ")
  8. gui.drawTitle()
  9.  
  10. queueOne    = util.load("__queueOne__")
  11. queueTwo    = util.load("__queueTwo__")
  12. iOne        = util.load("__iOne__")
  13. iTwo        = util.load("__iTwo__")
  14.  
  15. if queueOne == nil then
  16.     queueOne = {}
  17.     util.save("__queueOne__", queueOne)
  18. end
  19.  
  20. if queueTwo == nil then
  21.     queueTwo = {}
  22.     util.save("__queueTwo__", queueTwo)
  23. end
  24.  
  25. if iOne == nil then
  26.     iOne = 1
  27.     util.save("__iOne__", iOne)
  28. end
  29.  
  30. if iTwo == nil then
  31.     iTwo = 1
  32.     util.save("__iTwo__", iTwo)
  33. end
  34.  
  35. lenQueueOne = #queueOne
  36. lenQueueTwo = #queueTwo
  37.  
  38. commands = {
  39.     forward = function(arg) turtle.forward() end,
  40.     back = function(arg) turtle.back() end,
  41.     left = function(arg) turtle.turnLeft() end,
  42.     right = function(arg) turtle.turnRight() end,
  43.     up = function(arg) turtle.up() end,
  44.     down = function(arg) turtle.down() end,
  45.     digUp = function(arg) turtle.digUp() end,
  46.     digDown = function(arg) turtle.digDown() end,
  47.     dig = function(arg) turtle.dig() end
  48.     slot = function(arg) turtle.select(arg) end
  49.     drop = function(arg) turtle.drop(arg) end
  50.     dropUp = function(arg) turtle.dropUp(arg) end
  51.     dropDown = function(arg) turtle.dropDown(arg) end
  52. }
  53.  
  54. function handleCommand(instruction)
  55.     print(instruction[1])
  56.     commands[instruction[1]](instruction[2])
  57. end
  58.  
  59. -- Resume program
  60. if lenQueueOne > 0 then
  61.     running = true
  62.     while running do
  63.         instruction = queueOne[iOne]
  64.  
  65.         if instruction == nil then
  66.             running = false
  67.             print("end of queue")
  68.             next
  69.         end
  70.        
  71.         handleCommand(instruction)
  72.  
  73.         iOne = iOne + 1
  74.         util.save("__iOne__", iOne)
  75.  
  76.         if iOne > lenQueueOne then
  77.             running = false
  78.         end
  79.     end
  80.  
  81.     queueOne = {}
  82.     util.save("__queueOne__", queueOne)
  83.  
  84.     iOne = 1
  85.     util.save("__iOne__", iOne)
  86.     return
  87. end
  88.  
  89. --new run
  90. maxLength = gui.askNumber("Length")
  91. maxWidth = gui.askNumber("Width")
  92. maxLevels = gui.askNumber("Levels")
  93. direction = gui.askMessage("Direction", "left", "right")
  94.  
  95. function digUpDown()
  96.     table.insert(queueOne, {"digUp"})
  97.     table.insert(queueOne, {"digDown"})
  98. end
  99.  
  100. function digAll()
  101.     table.insert(queueOne, {"dig"})
  102.     digUpDown()
  103. end
  104.  
  105. function left()
  106.     table.insert(queueOne, {"left"})
  107. end
  108.  
  109. function right()
  110.     table.insert(queueOne, {"right"})
  111. end
  112.  
  113. function forward()
  114.     table.insert(queueOne, {"forward"})
  115. end
  116.  
  117. function newLane(lane)
  118.     if lane % 2 == 0 then
  119.         if direction == "right" then
  120.             left()
  121.             digAll()
  122.             forward()
  123.             left()
  124.         else
  125.             right()
  126.             digAll()
  127.             forward()
  128.             right()
  129.         end
  130.     else
  131.         if direction == "right" then
  132.             right()
  133.             digAll()
  134.             forward()
  135.             right()
  136.         else
  137.             left()
  138.             digAll()
  139.             forward()
  140.             left()
  141.         end
  142.     end
  143.  
  144.     digAll()
  145. end
  146.  
  147. z = 1
  148. while z <= maxLevels do
  149.     x = 1
  150.     while x < maxWidth do
  151.         y = 1
  152.         while y < maxLength do
  153.             digAll()
  154.             forward()
  155.             y = y + 1
  156.         end
  157.  
  158.         digUpDown()
  159.  
  160.         x = x + 1
  161.  
  162.         if x < maxWidth then
  163.             newLane(x)
  164.         end
  165.     end
  166.  
  167.     z = maxLevels
  168. end
  169.  
RAW Paste Data