This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

mine1x3

By: a guest on Mar 21st, 2013  |  syntax: Lua  |  size: 0.65 KB  |  views: 95  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. local args = {...}
  2. local distance = tonumber(args[1])
  3.  
  4. local counteddist = 0
  5.  
  6. local function digmove()
  7.   turtle.dig()
  8.   turtle.forward()
  9.   turtle.digUp()
  10.   turtle.digDown()
  11. end
  12.  
  13. local function countdist()
  14.   counteddist = counteddist + 1
  15.   print(counteddist)
  16. end
  17. local function returnback()
  18.   if distance == counteddist then
  19.     print("I'm done mining")
  20.     print("I should be returning home")
  21.     turtle.turnRight()
  22.     turtle.turnRight()
  23.     for i = 1, counteddist do
  24.       turtle.forward()
  25.     end
  26.     print("Am i home yet?")        
  27.   end  
  28. end
  29. --Main Script
  30.  
  31. for i = 1, distance do
  32.   digmove()
  33.   countdist()  
  34.   returnback()
  35. end
clone this paste RAW Paste Data