Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for k,v in pairs(rs.getSides()) do
- if peripheral.getType(v)=='monitor' then
- side = v
- mon = peripheral.wrap(side)
- break
- end
- end
- for k,v in pairs(rs.getSides()) do
- if peripheral.getType(v)=='modem' then
- rednet.open(v)
- break
- end
- end
- monX, monY = mon.getSize()
- detect =
- while true do
- rednet.receive()
- if id == detect and message == "new" then
- rednet.send(detect, "true")
- id, name = rednet.receive()
- rednet.send(detect, true)
- id, address = rednet.receive()
- table = {name = name, address = address}
- table = textutils.serialize(table)
- for i = 1, monY do
- if fs.exists(tostring(i)) == false then
- file = fs.open(tostring(i), "w")
- file.write(table)
- file.close()
- break
- end
- end
- elseif id == detect and message == "true" then
- mon.clear()
- for i = 1, monY do
- if fs.exists(i) then
- file = fs.open(i)
- data = file.readAll()
- file.close()
- data = textutils.unserialize(data)
- for key,value in pairs(data) do
- mon.setCursorPos(monX/2-string.len(tostring(key..": "..value))/2, i)
- mon.write(tostring(key..": "..value))
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement