Barnet

Minecraft Turtle: MoveSet

Apr 26th, 2016 (edited)
56
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Forward(x)
  2.   y=0
  3.   while y<x do
  4.     while turtle.forward() == false do
  5.       if turtle.detect() == true then
  6.         turtle.dig()
  7.       else
  8.         turtle.attack()
  9.       end
  10.     end
  11.     y=y+1
  12.   end
  13. end
  14.  
  15. function Left()
  16.   turtle.turnLeft()
  17. end
  18.  
  19. function Right()
  20.   turtle.turnRight()
  21. end
  22.  
  23. function Turn()
  24.   turtle.turnRight()
  25.   turtle.turnRight()
  26. end
  27.  
  28. function Up(x)
  29.   y=0
  30.   while y<x do
  31.     while turtle.up() == false do
  32.       if turtle.detectUp() == true then
  33.         turtle.digUp()
  34.       else
  35.         turtle.attackUp()
  36.       end
  37.     end
  38.     y=y+1
  39.   end
  40. end
  41.  
  42. function Down(x)
  43.   y=0
  44.   while y<x do
  45.     while turtle.down() == false do
  46.       if turtle.detectDown() == true then
  47.         turtle.digDown()
  48.       else
  49.         turtle.attackDown()
  50.       end
  51.     end
  52.     y=y+1
  53.   end
  54. end
  55.  
  56. function Help()
  57.   print("---------------------------------------")
  58.   print("-------------   Commands  -------------")
  59.   print("---------------------------------------")
  60.   print("------------- Forward - w -------------")
  61.   print("-------------    Left - a -------------")
  62.   print("-------------   Right - d -------------")
  63.   print("-------------    Turn - s -------------")
  64.   print("-------------      Up - W -------------")
  65.   print("-------------    Down - S -------------")
  66.   print("-------------    Exit - e -------------")
  67.   print("---------------------------------------")
  68.   print("---------------------------------------")
  69. end
  70.  
  71. ----main--------------------------------------
  72. Help()
  73. while true do
  74.   Input = read()
  75.   if Input == "w" then
  76.     Forward(1)
  77.   elseif Input == "a" or Input == "Left" or Input == "left" or Input == "l" or Input == "L" then
  78.     Left()
  79.   elseif Input == "d" or Input == "Right" or Input == "right" or Input == "r" or Input == "R" then
  80.     Right()
  81.   elseif Input == "s" then
  82.     Turn()
  83.   elseif Input == "W" then
  84.     Up(1)
  85.   elseif Input == "S" then
  86.     Down(1)
  87.   elseif Input == "e" or Input == "E" or Input == "Exit" or Input == "exit" or Input == "q" or Input == "Q" then
  88.     shell.run("clear")
  89.     return false
  90.   elseif Input == "Forward" or Input == "forward" or Input == "Move" or Input == "move" or Input == "F" or Input == "f" then
  91.     write("Forward: ")
  92.     x = tonumber(read())
  93.     Forward(x)
  94.   elseif Input == "Up" or Input == "up" or Input == "u" or Input == "U" then
  95.     write("Up: ")
  96.     x = tonumber(read())
  97.     Up(x)
  98.   elseif Input == "Down" or Input == "down"  then
  99.     write("Down: ")
  100.     x = tonumber(read())
  101.     Down(x)
  102.   end
  103.   Help()
  104. end
RAW Paste Data