Advertisement
S3mpx

move

May 20th, 2024 (edited)
531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Turtle Programm --
  2. -- Category: Movement/Mining --
  3.  
  4. -- [INFORMATION] --
  5. local appName = "Move.lua"
  6. local appType = "Turtle"
  7. local category = "Movement/Mining"
  8. local version = "1.0"
  9. local author = "S3mpx"
  10. -- print info --
  11. print("["..appName.."]")
  12. print("Programm Type: "..appType)
  13. print("Category: "..category)
  14. print("Version: "..version)
  15. print("written by"..author)
  16.  
  17. -- [LOCALS] --
  18.  
  19. local x = ""
  20. local y = ""
  21.  
  22. -- [FUNKTIONS] --
  23.  
  24. -- go(x) --
  25. local function go(x)
  26.     for i=1, x do
  27.         turtle.dig()
  28.         turtle.forward()
  29.     end
  30. end
  31.  
  32. -- up(x) --
  33. local function up(x)
  34.     for i=1, x do
  35.         turtle.digUp()
  36.         turtle.up()
  37.     end
  38. end
  39.  
  40. -- down(x) --
  41. local function down(x)
  42.     for i=1, x do
  43.         turtle.digDown()
  44.         turtle.down()
  45.     end
  46. end
  47.  
  48. -- left(x) --
  49. local function left(x)
  50.     turtle.turnLeft()
  51.     go(x)
  52. end
  53.  
  54. -- right(x) --
  55. local function right(x)
  56.     turtle.turnRight()
  57.     go(x)
  58. end
  59.  
  60. -- cobble(x) --
  61. local function cobble(x)
  62.     for i=1, x do
  63.         if turtle.detect() then
  64.             turtle.dig()
  65.         else
  66.             i = i-1
  67.         end
  68.     end
  69. end
  70.  
  71. -- emptyInventory --
  72. local function emptyInventory()
  73.     right(0)
  74.     right(0)
  75.     for slot = 1, 16 do
  76.         turtle.select(slot)
  77.         while turtle.getItemCount(slot) > 0 do
  78.             if not turtle.drop() then
  79.                 print("Chest is full or no chest behind. Exiting...")
  80.                 return false
  81.             end
  82.         end
  83.     end
  84.     right(0)
  85.     right(0)
  86.     return true
  87. end
  88.  
  89. -- [MAIN FUNKTION] --
  90.  
  91. print("When you're done, type 'done'!")
  92.  
  93. while true do
  94.     y = io.read()
  95.     if y == "empty" then
  96.         print("emptying inventory...")
  97.         emptyInventory()
  98.         print("success!")
  99.     end
  100.     if y == "cobble" then
  101.         print("how many blocks? (x)")
  102.         x = io.read()
  103.         cobble(x)
  104.     end
  105.     if y == "go" then
  106.         print("go(x)?")
  107.         x = io.read()
  108.         go(x)
  109.     end
  110.     if y == "up" then
  111.         print("up(x)?")
  112.         x = io.read()
  113.         up(x)
  114.     end
  115.     if y == "down" then
  116.         print("down(x)?")
  117.         x = io.read()
  118.         down(x)
  119.     end
  120.     if y == "left" then
  121.         print("left(x)?")
  122.         x = io.read()
  123.         left(x)
  124.     end
  125.     if y == "right" then
  126.         print("right(x)?")
  127.         x = io.read()
  128.         right(x)
  129.     end
  130. end
  131.  
  132. -- [END] --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement