Advertisement
chopstyix

worldEater

Feb 4th, 2022 (edited)
929
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.82 KB | None | 0 0
  1. local arg = {...}
  2. local x = tonumber(arg[1])
  3. local y = tonumber(arg[2])
  4. local poop = 0
  5.  
  6. function clearScreen()
  7.   term.clear()
  8.   term.setCursorPos(1,1)
  9. end
  10.  
  11. function zigzag()
  12.   if poop == 0 then
  13.     turtle.turnLeft()
  14.     turtle.forward()
  15.     turtle.turnLeft()
  16.     turtle.digDown()
  17.     poop = 1
  18.   elseif poop == 1 then
  19.     turtle.turnRight()
  20.     turtle.forward()
  21.     turtle.turnRight()
  22.     turtle.digDown()
  23.     poop = 0
  24.   else
  25.     print("dig() error!")
  26.   end
  27. end
  28.  
  29. function dig()
  30.   local myX, myY
  31.   for myY = 1, y do
  32.     for myX=1, x do
  33.       clearScreen()
  34.       print(turtle.getFuelLevel())
  35.       turtle.forward()
  36.       turtle.digDown()
  37.       if turtle.getItemCount(14) >= 1 then
  38.         unloadItems()
  39.       end
  40.     end
  41.     print("attempting zigzag")
  42.     zigzag() -- Zigs and Zags
  43.   end
  44. end
  45.  
  46. function readyCheck() -- Returns true if a chest is found in inventory slot 16.
  47.   local chest = turtle.getItemDetail(16)
  48.   if (chest == nil) or (chest == nil) then
  49.     print("I'm not prepared to mine!")
  50.     print("I need an Ender Chest in slot 16.")
  51.     print("Press any key to continue.")
  52.     os.pullEvent("key")
  53.     return false
  54.   else
  55.     return true
  56.   end  
  57. end
  58.  
  59. function unloadItems()
  60.   -- Rotate turtle to Rear
  61.   turtle.turnLeft()
  62.   turtle.turnLeft()
  63.   -- turtle selects ender chest
  64.   turtle.select(16)
  65.   -- turtle place ender chest
  66.   turtle.place()
  67.   -- turtle loops placing items into chest
  68.   for i=1,14 do
  69.     turtle.select(i)
  70.     turtle.drop()
  71.   end
  72.   -- turtle selects inv for ender chest
  73.   turtle.select(16)
  74.   -- turtle mines
  75.   turtle.dig()
  76.   -- turtle faces original direction
  77.   turtle.turnLeft()
  78.   turtle.turnLeft()
  79. end
  80.  
  81. -- MAIN CODE BEGINS --
  82. print("X:",x," Y:",y)
  83. print("poop:", poop)
  84. readyCheck()
  85. turtle.digDown()
  86. dig()
  87. while turtle.down() do
  88.   dig()
  89. end
  90. -- MAIN CODE ENDS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement