Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modem = peripheral.find("modem")
- if not modem then
- error("Requires a modem.")
- end
- modem.open(1251)
- term.setBackgroundColor(colors.black)
- term.clear()
- if prevnames == nil then
- prevnames = {}
- end
- term.setCursorPos(1,1)
- print("Enter your name")
- local name = read(nil,prevnames)
- if name:gsub(" ","") ~= "" then
- table.insert(prevnames,name)
- end
- names = { --Add names to quickly switch between using UP and DOWN
- name,
- "Jesus",
- "&4Console",
- "&4dan200",
- }
- local pos = 1
- local scr_x, scr_y = term.getSize()
- renderMenu = function()
- local x,y = term.getCursorPos()
- local bg = term.getBackgroundColor()
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,1)
- for a = 1, #names do
- if pos == a then
- write("*")
- else
- write(" ")
- end
- print(names[a])
- end
- term.setCursorPos(x,y)
- term.setBackgroundColor(bg)
- end
- function doRead()
- while true do
- term.setBackgroundColor(colors.black)
- term.clear()
- renderMenu()
- term.setCursorPos(1,1)
- term.setCursorPos(1,scr_y-1)
- term.setBackgroundColor(colors.gray)
- term.clearLine()
- term.setTextColor(colors.white)
- write(">")
- local msg = read()
- if msg:gsub(" ","") == "/exit" then
- return
- end
- if msg:gsub(" ","") ~= "" then
- modem.transmit(1251,1251,{names[pos],msg})
- end
- end
- end
- function changename()
- while true do
- local evt, key = os.pullEvent("key")
- if key == keys.up then
- pos = pos - 1
- end
- if key == keys.down then
- pos = pos + 1
- end
- if pos <= 0 then
- pos = #names
- elseif pos > #names then
- pos = 1
- end
- renderMenu()
- end
- end
- parallel.waitForAny(changename,doRead)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement