Advertisement
kovakovi2000

CC: P++ RNC - RedNetContinue

Apr 9th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. os.loadAPI("ldb2")
  2.  
  3. local db = "rnc"
  4. function setPort(_nPort)
  5. ldb2.set(db, "port", _nPort)
  6. end
  7.  
  8. function setIdenty(_nIdenty)
  9. ldb2.set(db, "identy", _nIdenty)
  10. end
  11.  
  12. function setTimeOut(_nTimeout)
  13. ldb2.set(db, "timeout", _nTimeout)
  14. end
  15.  
  16. setPort(80)
  17. setIdenty(45)
  18. setTimeOut(10)
  19.  
  20. local modem = peripheral.find("modem")
  21.  
  22. function resive()
  23. modem.open(ldb2.get(db, "port"))
  24. timer = os.startTimer( ldb2.get(db, "timeout") )
  25. while true do
  26. local event, side, fec, refec, message, distance = os.pullEvent()
  27. if event == "modem_message" then
  28. if refec == ldb2.get(db, "identy") then
  29. modem.close(ldb2.get(db, "port"))
  30. return textutils.unserialize(message)
  31. end
  32. elseif event == "timer" then
  33. if side == timer then
  34. break
  35. end
  36. end
  37. end
  38. return nil
  39. end
  40.  
  41. function send(message, vdebug)
  42. modem.open(ldb2.get(db, "port"))
  43. modem.transmit( ldb2.get(db, "port"), ldb2.get(db, "identy"), textutils.serialize(message))
  44. end
  45.  
  46. function close()
  47. modem.close(ldb2.get(db, "port"))
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement