Advertisement
Lanzr

pocket

Oct 28th, 2023
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. local turhost
  2. local procPlacer
  3. local retryTimes = 10
  4. print("pls appoint proc")
  5. rednet.open("back")
  6. procPlacer = io.read()
  7. -- procPlacer = io.stdin()
  8.  
  9. local function init()
  10. while 1 do
  11. turhost = rednet.lookup(procPlacer)
  12. if (turhost ~= nil) then
  13. print("find target!")
  14. return true
  15. end
  16. end
  17. print("target not found")
  18. return false
  19. end
  20.  
  21.  
  22. local function key_check()
  23. while true do
  24. local event, key, isHeld = os.pullEvent("key")
  25. if(turhost ~= nil) then
  26. local kvalue = keys.getName(key)
  27. rednet.send(turhost,kvalue,procPlacer)
  28. if (kvalue == "l") then
  29. print("procgram shutdown")
  30. os.sleep(3)
  31. return
  32. end
  33. end
  34. end
  35. end
  36.  
  37. local function net_check()
  38. while 1 do
  39. local event, sender, message, protocol = os.pullEvent("rednet_message")
  40. print(message)
  41. end
  42. end
  43.  
  44. if(init()) then
  45. parallel.waitForAny(net_check,key_check)
  46. end
  47.  
  48. term.clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement