xXm0dzXx

Untitled

Nov 9th, 2014
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. if turtle == nil then
  2. term.clear();
  3. term.setCursorPos(1, 1);
  4. print("Auto-turtle-programmer v6.8")
  5. print("-programs------------------")
  6. shell.run("rom/programs/list", "disk/turtle")
  7. print("---------------------------")
  8. return
  9. end
  10.  
  11. local tDir = "disk/turtle"
  12. if(fs.exists(tDir))then
  13. local tAll = fs.list( tDir )
  14. local tFiles = {}
  15. local tDirs = {}
  16.  
  17. fsm.delete("startup")
  18. fs.copy(fs.combine( tDir, "startup"), "startup")
  19.  
  20. for n, sItem in pairs( tAll) do
  21. local sPath = fs.combine( tDir, sItem );
  22. fs.delete(sItem)
  23. fs.copy(sPath, sItem);
  24. if string.sub(sItem, 1, 1) == "." then
  25. shell.run(sItem)
  26. end
  27. print("Got program: " .. sItem)
  28. end
  29.  
  30. turtle.refuel()
  31. turtle.up()
  32. turtle.up()
  33. end
  34.  
  35. rednet.open("right")
  36. rednet.send(155, "ayylmao:" .. os.getComputerLabel())
  37.  
  38. function handleMessages()
  39. while true do
  40. local id, message = rednet.receive()
  41. if(id == 155) then
  42. x, y, z = gps.locate()
  43. if (message == "x") then
  44. rednet.send(id, x)
  45. elseif(message == "y") then
  46. rednet.send(id, y)
  47. elseif(message == "z") then
  48. rednet.send(id, z)
  49. end
  50. end
  51. end
  52. end
  53.  
  54. function openShell()
  55. shell.run("shell")
  56. end
  57.  
  58. parallel.waitForAll(handleMessages, openShell)
Advertisement
Add Comment
Please, Sign In to add comment