Advertisement
DomMOW

BuildRoomDropOff

Jan 10th, 2021 (edited)
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.25 KB | None | 0 0
  1. --Min is 3 for H--
  2. lengthMax = 50
  3. widthMax = 3
  4. heightMax = 3
  5. orientation = 4
  6. --N=4, E=3, S=2, W=1--
  7. orientations = {"north", "east", "south", "west"}
  8. startDirection = orientation
  9.  
  10. xCurrent = 0
  11. zCurrent = 0
  12. yCurrent = 0
  13.  
  14. xHome = 0
  15. zHome = 0
  16. yHome = 0
  17.  
  18. xBlackcurrant = 0
  19. zBlackcurrant = 0
  20. yBlackcurrant = 0
  21. orientationLast = orientation
  22.  
  23. zDiff = {-1, 0, 1, 0}
  24. xDiff = {0, 1, 0 ,-1}
  25.  
  26. turn = 1
  27. turnLast = turn
  28. lengthCurrent = lengthMax
  29. placeTorch = 10
  30. width = widthMax
  31. finishWalk = widthMax
  32. heightMax = heightMax - 3
  33. height = heightMax
  34. ending = false
  35. kill = false
  36. said = false
  37. selectedSlot = 16
  38.  
  39. function torchCheck()
  40.     while not(turtle.getItemDetail("minecraft:torch")) do
  41.         if said == false then
  42.             print("Gimme Some Fookin Torches! Slot.1 Plz")
  43.             said = true
  44.             sleep(1)
  45.         end
  46.     end
  47.     said = false
  48. end
  49.  
  50. function left()
  51.   orientation = orientation - 1
  52.   orientation = (orientation - 1) % 4
  53.   orientation = orientation + 1
  54.  
  55.   turtle.turnLeft()
  56. end
  57.  
  58. function right()
  59.   orientation = orientation - 1
  60.   orientation = (orientation + 1) % 4
  61.   orientation = orientation + 1
  62.  
  63.   turtle.turnRight()
  64. end
  65.  
  66. function look(direction)
  67.     while direction ~= orientations[orientation] do
  68.       right()
  69.     end
  70. end
  71.  
  72. function moveForward()
  73.   while turtle.detect() do
  74.     turtle.dig()
  75.   end
  76.   moved = false
  77.   while not(moved) do
  78.     moved = turtle.forward()
  79.   end
  80.   xCurrent = xCurrent + xDiff[orientation]
  81.   zCurrent = zCurrent + zDiff[orientation]
  82. end
  83.  
  84. function digForward()
  85.   while turtle.detect() do
  86.     turtle.dig()
  87.   end
  88. end
  89.  
  90. function digBelow()
  91.   while turtle.detectDown() do
  92.     turtle.digDown()
  93.   end
  94. end
  95.  
  96. function digAbove()
  97.   while turtle.detectUp() do
  98.     turtle.digUp()
  99.   end
  100. end
  101.  
  102. function moveUp()
  103.   turtle.digUp()
  104.   moved = false
  105.   while not(moved) do
  106.     digAbove()
  107.     moved = turtle.up()
  108.   end
  109.   yCurrent = yCurrent + 1
  110. end
  111.  
  112. function moveDown()
  113.   turtle.digDown()
  114.   moved = false
  115.   while not(moved) do
  116.     moved = turtle.down()
  117.   end
  118.   yCurrent = yCurrent - 1
  119. end
  120.  
  121. function goDown()
  122.   moved = false
  123.   while not(moved) do
  124.     turtle.digDown()  
  125.     moved = turtle.down()
  126.   end
  127.   yCurrent = yCurrent - 1
  128. end
  129.  
  130. function goUp()
  131.     moved = false
  132.     while not(moved) do
  133.         digAbove()
  134.       moved = turtle.up()
  135.     end
  136.     yCurrent = yCurrent + 1
  137. end
  138.  
  139. function upBreak()
  140.   digAbove()
  141.   goUp()
  142.   digAbove()
  143. end
  144.  
  145. function leftDig()
  146.   left()
  147.   moveForward()
  148.   digAbove()
  149.   digBelow()
  150.   while height > 0 do
  151.     upBreak()
  152.     height = height - 1
  153.   end
  154.   height = heightMax
  155.   while height > 0 do
  156.     moveDown()
  157.     height = height - 1
  158.   end
  159.   height = heightMax
  160.   left()
  161. end
  162.  
  163. function rightDig()
  164.   right()
  165.   moveForward()
  166.   digAbove()
  167.   digBelow()
  168.   while height > 0 do
  169.     upBreak()
  170.     height = height - 1
  171.   end
  172.   height = heightMax
  173.   while height > 0 do
  174.     moveDown()
  175.     height = height - 1
  176.   end
  177.   height = heightMax
  178.   right()
  179. end
  180.  
  181. function leftWalk()
  182.   left()
  183.   moveForward()
  184.   digAbove()
  185.   digBelow()
  186.   while height > 0 do
  187.     upBreak()
  188.     height = height - 1
  189.   end
  190.   height = heightMax
  191.   while height > 0 do
  192.     moveDown()
  193.     height = height - 1
  194.   end
  195.   height = heightMax
  196. end
  197.    
  198. function rightWalk()
  199.   right()
  200.   moveForward()
  201.   digAbove()
  202.   digBelow()
  203.   while height > 0 do
  204.     upBreak()
  205.     height = height - 1
  206.   end
  207.   height = heightMax
  208.   while height > 0 do
  209.     moveDown()
  210.     height = height - 1
  211.   end
  212.   height = heightMax
  213. end
  214.  
  215. function goto(xHome, zHome, yHome)
  216.     while yHome < yCurrent do
  217.         moveDown()
  218.     end
  219.     while yHome > yCurrent do
  220.         moveUp()
  221.     end
  222.     if xHome < xCurrent then
  223.       look("west")
  224.       while xHome < xCurrent do
  225.         moveForward()
  226.       end
  227.     end
  228.     if xHome > xCurrent then
  229.       look("east")
  230.       while xHome > xCurrent do
  231.         moveForward()
  232.       end
  233.     end
  234.     if zHome < zCurrent then
  235.       look("north")
  236.       while zHome < zCurrent do
  237.         moveForward()
  238.       end
  239.     end
  240.     if zHome > zCurrent then
  241.       look("south")
  242.       while zHome > zCurrent do
  243.         moveForward()
  244.       end
  245.     end
  246.     while not(orientation == startDirection) do
  247.         right()
  248.     end
  249. end
  250.  
  251. function dropItems()
  252.     turtle.select(16)
  253.     selectedSlot = 16
  254.     while not(selectedSlot == 1) do
  255.         turtle.drop()
  256.         selectedSlot = selectedSlot - 1
  257.         turtle.select(selectedSlot)
  258.     end
  259. end
  260.  
  261. function lookLast()
  262.     while not(orientation == orientationLast) do
  263.         right()
  264.     end
  265. end
  266.  
  267. function dropOff()
  268.     xBlackcurrant = xCurrent
  269.     zBlackcurrant = zCurrent
  270.     yBlackcurrant = yCurrent
  271.     orientationLast = orientation
  272.     turtle.select(16)
  273.     if turtle.getItemCount() > 0 then
  274.         print("Going to Drop Off")
  275.         goto(xHome, zHome, yHome)
  276.         dropItems()
  277.         goto(xBlackcurrant, zBlackcurrant, yBlackcurrant)
  278.         lookLast()
  279.     elseif turtle.getItemCount() == 0 then
  280.         turtle.select(1)
  281.     end
  282. end
  283.  
  284. while true do
  285.   if lengthCurrent > 0 and ending == false then
  286.     dropOff()
  287.     torchCheck()
  288.     moveForward()
  289.     digAbove()
  290.     digBelow()
  291.     while height > 0 do
  292.       upBreak()
  293.       height = height - 1
  294.     end
  295.     height = heightMax
  296.     while height > 0 do
  297.       moveDown()
  298.       height = height - 1
  299.     end
  300.     height = heightMax
  301.     placeTorch = placeTorch - 1
  302.     lengthCurrent = lengthCurrent - 1
  303.     if placeTorch <= 0 then
  304.       placeTorch = 10
  305.       turtle.placeDown()
  306.     end
  307.   end
  308.   if lengthCurrent <= 0 and turn == 1 and width > 0 then
  309.     width = width - 1
  310.     if width > 0 then
  311.       rightDig()
  312.       lengthCurrent = lengthMax
  313.       turn = 2
  314.       print("Turned Right")
  315.     end
  316.   end
  317.   if lengthCurrent <= 0 and turn == 2 and width > 0 then
  318.     width = width - 1
  319.     if width > 0 then
  320.       leftDig()
  321.       lengthCurrent = lengthMax
  322.       turn = 1
  323.       print("Turned Left")
  324.     end
  325.   end
  326.   if width <= 0 then
  327.     turnLast = turn
  328.     turn = 3
  329.     ending = true
  330.   end
  331.   if width <= 0 and turn == 3 and ending == true then
  332.     print("Final Walk Home")
  333.     goto(xHome, zHome, yHome)
  334.     kill = true
  335.     turn = 4
  336.   end
  337.   if kill == true then
  338.     print("Killing the Program")
  339.     error()
  340.   end
  341. end
  342.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement