Advertisement
k_goos

ServerQuarry

Apr 24th, 2013
93
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local count = 0
  2. local turtles = {}
  3. local par1 = ""
  4. local par2 = ""
  5.  
  6. function Register()
  7. while true do
  8. id, mes = rednet.receive()
  9. if mes == "register" then
  10. known = false
  11.  
  12. for i=0, count do
  13. if turtles[i] == id then
  14. known = true
  15. end
  16. end
  17.  
  18. if known == false then
  19. print("Register: "..id)
  20. turtles[count] = id
  21. rednet.send(id, "registerdone")
  22. count = count + 1
  23. end
  24. end
  25. end
  26. end
  27. function SendAll(message)
  28. for i = 0, count-1 do
  29. print(turtles[i]..": "..message)
  30. rednet.send(turtles[i], message)
  31. end
  32. end
  33.  
  34. function ChechRegisterCount()
  35. while count == 0 do
  36. print("No turtles connected")
  37. sleep(2)
  38. end
  39. end
  40. function Main()
  41. while true do
  42. ChechRegisterCount()
  43.  
  44. for i=0, 10 do
  45. SendAll("Place")
  46. sleep(8)
  47. SendAll("Pick")
  48. sleep(5)
  49. print("Forward...")
  50. shell.run("Forward")
  51. end
  52. end
  53. end
  54.  
  55. rednet.open("right")
  56. parallel.waitForAny(Register, Main)
  57. rednet.close("right")
Advertisement
RAW Paste Data Copied
Advertisement