Advertisement
leo1553

Untitled

Jan 14th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  1. -- Vars
  2. local args = {...}
  3. local startTime
  4. local lastTime
  5.  
  6. -- Functions
  7. function GoForward()
  8.     while(turtle.forward() == true) do
  9.     end
  10. end
  11.  
  12. function GoBack()
  13.     while(turtle.back() == true) do
  14.     end
  15. end
  16.  
  17. function DoWork()
  18.     redstone.setOutput("bottom", true)
  19.     sleep(0.1)
  20.     redstone.setOutput("bottom", false)
  21.  
  22.     while(turtle.forward() == true) do
  23.         redstone.setOutput("bottom", true)
  24.         sleep(0.1)
  25.         redstone.setOutput("bottom", false)
  26.     end
  27.     GoBack()
  28. end
  29.  
  30. -- Code
  31. if(args[1] == nil) then
  32.     print("Error: Smeltery <time (s)>")
  33.     print("Note: 14 seconds = 1 go")
  34.     return
  35. end
  36.  
  37. GoForward()
  38. turtle.turnLeft()
  39. turtle.turnLeft()
  40.  
  41. startTime = os.clock()
  42. while(true) do
  43.     lastTime = os.clock()
  44.     if(lastTime - startTime + 14 > tonumber(args[1])) then
  45.         print("Job done after ".. lastTime - startTime .." seconds.")
  46.         return
  47.     end
  48.     DoWork()
  49.     while(true) do
  50.         sleep(1)
  51.         if(os.clock() - lastTime >= 14) then
  52.             break
  53.         end
  54.     end
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement