Advertisement
k_goos

FrameQuarry

Apr 23rd, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. local file = 'turtles.lua'
  2. local lines
  3.  
  4. function ReadFile(file)
  5. if not FileExists(file) then
  6. return {}
  7. end
  8.  
  9. lines = {}
  10. for line in io.lines(file) do
  11. lines[#lines + 1] = line
  12. end
  13. return lines
  14. end
  15. function FileExists(file)
  16. local f = io.open(file, "rb")
  17.  
  18. if f then
  19. f:close()
  20. end
  21.  
  22. return f ~= nil
  23. end
  24. function SendMessage(message)
  25. for n in lines do
  26. rednet.send(n, message)
  27. end
  28. end
  29. function Forward()
  30. redstone.setOutput("left", true)
  31. sleep(2)
  32. redstone.setOutput("left", false)
  33. redstone.setOutput("back", true)
  34. sleep(2)
  35. redstone.setOutput("back", false)
  36. end
  37. function Main()
  38. if #args > 1 or #args < 1 then
  39. print("Invalid number of arguments.")
  40. else
  41. count = args[1]
  42. end
  43.  
  44. lines = ReadFile(file)
  45.  
  46. Rednet.open()
  47. for i = 0, count do
  48.  
  49. SendMessage("place")
  50. Rednet.close()
  51.  
  52. sleep(20)
  53.  
  54. Rednet.open()
  55. SendMessage("drop")
  56. SendMessage("break")
  57.  
  58. Forward()
  59. end
  60. Rednet.close()
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement