Advertisement
DomMOW

BuildRoomChildFriendly

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