Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Created by eor84
- -- Please Give Credit it Edited
- local inputThread = nill
- local input = ""
- local x = 3
- function checkX()
- if x == 16 then
- print("")
- x = 15
- end
- end
- function clear()
- term.setCursorPos(1,1)
- term.clearLine()
- if term.isColor() then
- term.setBackgroundColor(colors.blue)
- end
- print("[ Tech Chat V3 ] =========== [ Use 'exit' To Exit ]")
- term.setCursorPos(1,2)
- term.clearLine()
- print("===================================================")
- term.setCursorPos(1,17)
- term.clearLine()
- print("===================================================")
- if term.isColor() then
- term.setBackgroundColor(colors.black)
- end
- term.setCursorPos(1,19)
- term.clearLine()
- term.setCursorPos(1,16)
- term.clearLine()
- term.setCursorPos(1,3)
- term.clearLine()
- term.setCursorPos(1,4)
- end
- function getInput()
- while true do
- clear()
- if term.isColor() then
- term.setTextColor(colors.lime)
- end
- term.setCursorPos(1,18)
- term.clearLine()
- term.write("Message: ")
- if term.isColor() then
- term.setTextColor(colors.white)
- end
- input = read()
- if string.sub(input, 1, 1) == "/" then
- local cmd = {}
- for match in string.gmatch(input, "[^%s]+") do
- table.insert(cmd, match)
- end
- if cmd[1] == "/exit" then
- if term.isColor() then
- term.setTextColor(colors.red)
- end
- x = x + 1
- checkX()
- term.setCursorPos(1,x)
- print("Exiting Tech Chat...")
- --rednet.broacast(name.. " Has Left The Chat")
- sleep(2)
- os.reboot()
- elseif cmd[1] == "/me" then
- msg = "*"..name.." "..table.concat(cmd, " ", 2)
- x = x + 1
- checkX()
- print(msg) -- right here
- rednet.broadcast(msg)
- elseif cmd[1] == "/kill" then
- if cmd[2] then
- msg = "*" ..name.. " kills "..cmd[2].."."
- else
- msg = "*" ..name.. " kills himself."
- end
- x = x + 1
- checkX()
- print(msg)
- rednet.broadcast(msg)
- --elseif cmd[1] == "/kill"
- elseif cmd[1] == "/slap" then
- msg = "*" ..name.. " slaps " ..cmd[2] or "someone".. "."
- x = x + 1
- checkX()
- print(msg)
- rednet.broadcast(msg)
- elseif cmd[1] == "/help" or cmd[1] == "/?" then
- x = x + 1
- checkX()
- print("/me, /kill, /slap")
- end
- --elseif cmd[1] == "" then
- --getInput()
- --end
- else
- x = x + 1
- checkX()
- term.setCursorPos(1,x)
- if term.isColor() then
- term.setTextColor(colors.lime)
- end
- term.write("(" ..os.getComputerID().. ") " ..name.. ": ")
- term.setTextColor(colors.white)
- term.write(input)
- local msg = name.. ": " ..input
- rednet.broadcast(msg)
- end
- end
- end
- function newInputThread()
- return coroutine.create(getInput)
- end
- function writeReceivedMessage(msg)
- --local xPos, yPos = term.getCursorPos()
- x = x + 1
- checkX()
- term.setCursorPos(1,x)
- print("[" ..msg)
- term.setCursorPos(10,18)
- end
- print("o")
- function listen()
- rednet.open("top")
- rednet.open("bottom")
- rednet.open("back")
- rednet.open("front")
- rednet.open("right")
- rednet.open("left")
- inputThread = newInputThread()
- coroutine.resume(inputThread)
- while true do
- local event = {os.pullEvent()}
- if event[1] == "rednet_message" then
- writeReceivedMessage(event[2] .. ": " .. event[3])
- event = {}
- end
- coroutine.resume(inputThread, unpack(event))
- end
- end
- os.pullEvent = os.pullEventRaw
- term.clear()
- clear()
- print("What is your name?")
- if term.isColor() then
- term.setTextColor(colors.lime)
- end
- name = read()
- if term.isColor() then
- term.setTextColor(colors.lime)
- end
- term.clear()
- if term.isColor() then
- term.setTextColor(colors.white)
- end
- clear()
- listen()
- print("k")
- rednet.broadcast(name.. " Has Joined The Chat")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement