Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w,h = term.getSize()
- local buffer = {}
- function initBuffer()
- for x=1,w do
- buffer[x] = {}
- for y = 1,h do
- buffer[x][y] = {}
- end
- end
- end
- function writeToBuffer(char,col,back,x,y)
- buffer[x][y] = {char,col,back}
- end
- function displayBuffer()
- rednet.broadcast(textutils.serialize(buffer),"stream")
- for x = 1, #buffer do
- for y = 1, #buffer[x] do
- term.setCursorPos(x,y)
- if #buffer[x][y] == 3 then
- term.setTextColor(buffer[x][y][2])
- term.setBackgroundColor(buffer[x][y][3])
- term.write(buffer[x][y][1])
- end
- end
- end
- end
- term.clear()
- initBuffer()
- term.setCursorPos(1,1)
- local cx,cy = 1,1
- while true do
- local e = {coroutine.yield()}
- if e[1] == "char" then
- writeToBuffer(e[2],123,43,cx,cy)
- displayBuffer()
- if cx == w then
- cx = 1
- cy = cy + 1
- elseif cx < w then
- cx = cx + 1
- end
- elseif e[1] == "key" then
- if e[2] == keys.enter then
- cy = cy + 1
- cx = 1
- elseif e[2] == keys.backspace then
- if cx > 1 then
- cx = cx - 1
- elseif cx == 1 then
- cx = w
- cy = cy - 1
- end
- writeToBuffer(" ",colors.black,colors.black,cx,cy)
- displayBuffer()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement