9551

Untitled

Jul 4th, 2021
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.81 KB | None | 0 0
  1. local wait = sleep -- My Dumbass way of typing wait instead of sleep
  2.  
  3. local turtX = 0 -- Positioning and movement Variables
  4. local turtY = 0
  5. local turtZ = 0
  6. local facing = 0
  7. local hasDugRight = false
  8. local hasDugLeft = false
  9. local emptyWasteBlocks = false
  10.  
  11. local fullSlots = 0 -- Inventory Variables
  12.  
  13. local totalDug = 0 -- Misc Variables
  14.  
  15. local fuels = {
  16.     -- Blocks and items that a turtle can use for fuel
  17.     "minecraft:charcoal",
  18.     "minecraft:coal",
  19.     "minecraft:coal_block",
  20.     "minecraft:oak_log",
  21.     "minecraft:oak_planks",
  22.     "minecraft:oak_slab",
  23.     "minecraft:oak_stairs",
  24.     "minecraft:oak_fence",
  25.     "minecraft:oak_pressure_plate",
  26.     "minecraft:chest",
  27.     "minecraft:crafting_table",
  28.     "minecraft:oak_trapdoor"
  29. }
  30.  
  31. local gravityBlocks = {
  32.     -- List of blocks effected by gravity
  33.     "minecraft:sand",
  34.     "minecraft:red_sand",
  35.     "minecraft:gravel"
  36. }
  37.  
  38. local wasteBlocks = {
  39.     -- List of blocks that you might not want to collect
  40.     "minecraft:gravel",
  41.     "minecraft:dirt",
  42.     "minecraft:cobblestone",
  43.     "minecraft:netherrack",
  44.     "minecraft:granite",
  45.     "minecraft:andesite",
  46.     "minecraft:diorite"
  47. }
  48.  
  49. local function isPositive(a)
  50.     if a >= 0 then
  51.         return true
  52.     else
  53.         return false
  54.     end
  55. end
  56.  
  57. local function dig()
  58.     turtle.dig()
  59.     totalDug = totalDug + 1
  60. end
  61.  
  62. local function digUp()
  63.     turtle.digUp()
  64.     totalDug = totalDug + 1
  65. end
  66.  
  67. local function digDown()
  68.     turtle.digDown()
  69.     totalDug = totalDug + 1
  70. end
  71.  
  72. local function checkFull()
  73.     fullSlots = 0
  74.     local search = 0
  75.     for search = 16, 1, -1 do
  76.         turtle.select(search)
  77.         if turtle.getItemCount() > 0 then
  78.             if turtle.getItemDetail().name == fuels then
  79.                 if turtle.getFuelLevel() <= getFuelLimit() - 64 then
  80.                     turtle.refuel()
  81.                 end
  82.             end
  83.         end
  84.         if turtle.getItemCount() > 0 then
  85.             fullSlots = fullSlots + 1
  86.         end
  87.     end
  88.     if fullSlots == 16 then
  89.         empty()
  90.     end
  91. end
  92.  
  93. local function turnRight()
  94.     turtle.turnRight()
  95.     if facing == 0 then
  96.         facing = 1
  97.     elseif facing == 1 then
  98.         facing = 2
  99.     elseif facing == 2 then
  100.         facing = 3
  101.     elseif facing == 3 then
  102.         facing = 0
  103.     end
  104. end
  105.  
  106. local function turnLeft()
  107.     trutle.turnLeft()
  108.     if facing == 0 then
  109.         facing = 3
  110.     elseif facing == 1 then
  111.         facing = 0
  112.     elseif facing == 2 then
  113.         facing = 1
  114.     elseif facing == 3 then
  115.         facing = 2
  116.     end
  117. end
  118.  
  119. local function forward()
  120.     turtle.forward()
  121.     if facing == 0 then
  122.         turtX = turtX + 1
  123.     elseif facing == 1 then
  124.         turtZ = turtZ + 1
  125.     elseif facing == 2 then
  126.         turtX = turtX - 1
  127.     elseif facing == 3 then
  128.         turtZ = turtZ - 1
  129.     end
  130. end
  131.  
  132. local function backward()
  133.     turtle.backward()
  134.     if facing == 0 then
  135.         turtX = turtX - 1
  136.     elseif facing == 1 then
  137.         turtZ = turtZ - 1
  138.     elseif facing == 2 then
  139.         turtX = turtX + 1
  140.     elseif facing == 3 then
  141.         turtZ = turtZ + 1
  142.     end
  143. end
  144.  
  145. local function up()
  146.     turtle.up()
  147.     local turtY = turtY + 1
  148. end
  149.  
  150. local function down()
  151.     turtle.down()
  152.     local turtY = turtY - 1
  153. end
  154.  
  155. local function checkForGravityBlocks()
  156.     local has_block, name = turtle.inspect()
  157.     for i = 1, 10 do
  158.         if has_block then
  159.             if name.name == gravityBlocks then
  160.                 dig()
  161.                 wait(0.25)
  162.             end
  163.         end
  164.     end
  165. end
  166.  
  167. local function adjustY()
  168.     if isPositive(roomY) then
  169.         up()
  170.         for i = 1, 2 do
  171.             if turtle.detectUp() then
  172.                 digUp()
  173.                 up()
  174.             else
  175.                 up()
  176.             end
  177.         end
  178.     else
  179.         down()
  180.         for i = 1, 2 do
  181.             if turtle.detectDown() then
  182.                 digDown()
  183.                 down()
  184.             else
  185.                 down()
  186.             end
  187.         end
  188.     end
  189. end
  190.  
  191. local function digRight()
  192.     hasDugLeft = false
  193.     hasDugRight = true
  194.     turnRight()
  195.     dig()
  196.     checkForGravityBlocks()
  197.  
  198.     for i = 1, roomX do
  199.         dig()
  200.         checkForGravityBlocks()
  201.     end
  202. end
  203.  
  204. local function digLeft()
  205. end
  206.  
  207. print("What are the room dimensions? X(forward) Y(up or down) Z(sideways)")
  208. print('If down put "-" before the number')
  209. print("X: ")
  210. local roomX = toNumber(read())
  211. print("Y: ")
  212. local roomY = toNumber(read())
  213. Print("Z: ")
  214. local roomZ = toNumber(read())
  215. term.clear()
  216. term.setCursorPos(1, 1)
  217.  
  218. print('Remove waste blocks? "y" or "n"')
  219. print(wasteBlocks)
  220. term.clear()
  221. term.setCursorPos(1, 1)
  222.  
  223. local result = read()
  224. if result == "y" then
  225.     emptyWasteBlocks = true
  226. elseif result == "n" then
  227.     emptyWasteBlocks = false
  228. end
  229.  
  230. while true do
  231. end
  232.  
Add Comment
Please, Sign In to add comment