Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modem = peripheral.find("modem")
- local mtable = {}
- local w, h = term.getSize()
- os.loadAPI("ea")
- function clear()
- ea.sbc(colors.white)
- term.clear()
- ea.stc(colors.blue)
- ea.scp(1,18)
- ea.sbc(colors.gray)
- write("<Type /help for help>")
- ea.sbc(colors.white)
- ea.scp(1,19)
- write("[::> ")
- ea.scp(6,19)
- end
- function start()
- ea.sbc(colors.white)
- ea.stc(colors.black)
- term.clear()
- ea.scp(16,9)
- print("Kosy Chat System")
- ea.scp(13,11)
- print("Username: ")
- ea.scp(13,12)
- print("Channel : ")
- ea.scp(22,11)
- us = io.read()
- ea.scp(22,12)
- ch = io.read()
- modem.open(tonumber(ch))
- clear()
- chatgo()
- end
- function drawm()
- if(#mtable > h-2)then local tt = mtable[h-2] mtable = {} table.insert(mtable,tt) tt = "" end
- for i = 1, #mtable do
- ea.scp(1,i)
- print(mtable[i])
- end
- end
- function receive()
- e = {os.pullEvent("modem_message")}
- table.insert(mtable, e[5])
- end
- function send()
- ea.scp(7,19)
- readm = read()
- modem.transmit(tonumber(ch), tonumber(ch), "<"..us..">: "..readm)
- clear()
- end
- function chatgo()
- while true do
- drawm()
- parallel.waitForAny(send, receive)
- end
- end
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement