Advertisement
SkyFlash21

Client

Jul 20th, 2021 (edited)
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. local modem = peripheral.wrap("left")
  2. rednet.open("left")
  3. IDserv = 0
  4.  
  5. function split(s, sep)
  6. local fields = {}
  7.  
  8. local sep = sep or " "
  9. local pattern = string.format("([^%s]+)", sep)
  10. string.gsub(s, pattern, function(c) fields[#fields + 1] = c end)
  11.  
  12. return fields
  13. end
  14.  
  15.  
  16. print("Bienvenu dans le proggrame client des robot MK1")
  17. shell.run('clear')
  18. print("Recheche du serveur ")
  19. print("Veillez lancer l'étape 1 sur le serveur.")
  20.  
  21.  
  22. while true do
  23. a,b = rednet.receive()
  24. if b == "Ping" then
  25. print("Ping recu")
  26. rednet.send(a, "Pong")
  27. print("Confimation envoyé")
  28. print("En attende d'instruction...")
  29. IDserv = a
  30. break
  31. end
  32. end
  33.  
  34. while true do
  35. local id = ""
  36. local name = ""
  37. event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  38. print(message)
  39. RunArg= split(message, ",")
  40. for i in RunArg do
  41. print(i)
  42. end
  43. if RunArg[0]:lower() == "quarry" then
  44. local file = io.open( "startup", "w" )
  45. text = "shell.run(\"rm Quarry)\nshell.run(\"pastebin get 1VvKnTDw Quarry)\nshell.run(\"Quarry,"..RunArg[1] .. ","..RunArg[2].. ","..IDserv..","..senderDistance.."\")"
  46. file:write(text)
  47. file:close()
  48. end
  49. print(RunArg[0])
  50. rednet.send(tonumber(id), "Done")
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement