Advertisement
SkyFlash21

Server

Jul 20th, 2021 (edited)
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. local modem = peripheral.wrap("right")
  2. print("Proggrame Serveur des robot MK1")
  3. sleep(0.5)
  4. robotlist = {}
  5. function AddRobot()
  6. print("Fonction d'ajout de robot :")
  7. print("---------------------------------------")
  8. turtleid = ""
  9. while turtleid == "" do
  10. shell.run('clear')
  11. print("Saisir l'id de la tortue...")
  12. local id = tonumber(string.match(read(), "%d*"))
  13. rednet.send(id, "Ping")
  14. print("Ping de la tortue (10s max)")
  15. local rip,rmessage = rednet.receive(10)
  16. if rmessage == "Pong" then
  17. turtleid = id
  18. shell.run('clear')
  19. local robot = {id,"neutre","",0}
  20. table.insert(robotlist, robot)
  21. print("Robot confirmé")
  22. sleep(1.5)
  23. break
  24. end
  25. printError("Aucune réponse de la tortue")
  26. printError("Vérifier l'id")
  27. print()
  28. print("Appuyer sur une touche pour continuer.")
  29. sleep(2)
  30. end
  31. shell.run('clear')
  32. print("Configuration du robot:")
  33. print("---------------------------------------")
  34. print("Fonction disponible:")
  35. print("Quarry:")
  36. local result = ""
  37. while result ~= "quarry" do
  38. result = read():lower()
  39. if result == "quarry" then
  40. shell.run('clear')
  41. print("Configuration de la quarry")
  42. print("---------------------------------------")
  43.  
  44. print("Saisir la largeur :")
  45. local largeur = read()
  46.  
  47. print("Saisir la longueur :")
  48. local longueur = read()
  49.  
  50. rednet.send(turtleid, "Quarry,"..largeur..","..longueur)
  51. end
  52. end
  53.  
  54.  
  55. end
  56.  
  57. function CheckRobot(i)
  58. id,status,info,fuel = i
  59. print("Traitement du robot n°" .. id .. " en cours")
  60. print("Envoie du ping; timeout 30s...")
  61. rednet.send(id, "status")
  62. if rednet.receive(10) == "nil" then
  63. print("Un erreur a eux lieux avec le robot ")
  64. end
  65.  
  66. end
  67. AddRobot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement