Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mon = peripheral.find("monitor")
- local speaker = peripheral.wrap("left")
- local sFile = "data.txt"
- local accent,range = "en",100
- function writemon(msg)
- if mon then
- mon.write(msg)
- mX,mY = mon.getCursorPos()
- mon.setCursorPos(1,mY+1)
- end
- end
- function writeln(msg)
- print(msg)
- tX,tY = term.getCursorPos()
- writemon(msg)
- end
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- if mon then
- mon.clear()
- mon.setCursorPos(1,1)
- end
- end
- function getUsername()
- if fs.exists(sFile) then
- local hRead = assert(fs.open(sFile, "r"))
- username = hRead.readAll()
- hRead.close()
- end
- end
- rednet.open("back")
- username = "Steve"
- function help()
- writeln("Welcome to some shit chat")
- writeln("Press H to set your Handle")
- writeln("Press A to change the Accent")
- writeln("Press T to Type in the chat")
- writeln("Press E to Exit the program")
- writeln("Press R to adjust the Range")
- end
- clear()
- getUsername()
- help()
- while true do
- event, id, msg = os.pullEvent()
- if event == "rednet_message" then
- writeln(msg)
- spk = msg:gsub('%<[^)]*%>', "")
- speaker.speak(spk, range, accent)
- elseif event == "char" then
- if id == "t" then
- write("<"..username.."> ")
- msgsent = read()
- speaker.speak(msgsent, range, accent)
- writemon("<"..username.."> "..msgsent)
- rednet.broadcast("<"..username.."> "..msgsent)
- elseif id == "h" then
- write("New username: ")
- username = read()
- hWrite = fs.open(sFile, "w")
- hWrite.write(username)
- hWrite.close()
- elseif id == "a" then
- write("New accent: ")
- accent = read()
- elseif id == "r" then
- write("New range: ")
- range = read()
- elseif id == "e" then
- error("Quit program")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment