Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ldb2")
- local db = "rnc"
- function setPort(_nPort)
- ldb2.set(db, "port", _nPort)
- end
- function setIdenty(_nIdenty)
- ldb2.set(db, "identy", _nIdenty)
- end
- function setTimeOut(_nTimeout)
- ldb2.set(db, "timeout", _nTimeout)
- end
- setPort(80)
- setIdenty(45)
- setTimeOut(10)
- local modem = peripheral.find("modem")
- function resive()
- modem.open(ldb2.get(db, "port"))
- timer = os.startTimer( ldb2.get(db, "timeout") )
- while true do
- local event, side, fec, refec, message, distance = os.pullEvent()
- if event == "modem_message" then
- if refec == ldb2.get(db, "identy") then
- modem.close(ldb2.get(db, "port"))
- return textutils.unserialize(message)
- end
- elseif event == "timer" then
- if side == timer then
- break
- end
- end
- end
- return nil
- end
- function send(message, vdebug)
- modem.open(ldb2.get(db, "port"))
- modem.transmit( ldb2.get(db, "port"), ldb2.get(db, "identy"), textutils.serialize(message))
- end
- function close()
- modem.close(ldb2.get(db, "port"))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement