Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- local m = peripheral.find("modem") -- Yay for CC1.6
- local flines = {}
- local nick = "Luca"
- local x, y = term.getSize()
- local f = fs.open(args[1],"r")
- for fline in f.readLine do
- flines[#flines+1] = fline
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Welcome to Chat!")
- print("IDs im Chatraum:")
- for i = 1,#flines do
- print(flines[i])
- m.open(tonumber(flines[i]))
- end
- sleep(3)
- term.clear()
- local line = 1
- local msg = ""
- while true do
- term.setCursorPos(1, y)
- term.clearLine()
- write("Message:"..msg)
- local e = {os.pullEvent()}
- if e[1] == "char" then
- msg = msg..e[2]
- elseif e[1] == "modem_message" then
- if line == y -1 then
- term.clear()
- line = 1
- end
- term.setCursorPos(1, line)
- print(e[5])
- line = line + 1
- elseif e[1] == "key" then
- if e[2] == 14 then
- term.setCursorPos(1,1)
- msg = msg:sub(0,#msg-1)
- end
- if e[2] == 28 then
- msg = "<"..nick..">"..msg
- if line == y -1 then
- term.clear()
- line = 1
- end
- term.setCursorPos(1, line)
- print(msg)
- line = line + 1
- m.transmit(os.getComputerID(),os.getComputerID(),msg)
- msg = ""
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement