Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w,h = term.getSize()
- term.clear()
- local console = window.create(term.current(),w/2,1,w,h/2)
- console.setCursorBlink(false)
- function showConsole()
- if visible then
- console.setVisible(false)
- visible = false
- console.redraw()
- else
- console.setVisible(true)
- visible = true
- console.redraw()
- end
- end
- function clear()
- console.setBackgroundColor(colors.white)
- console.setTextColor(colors.blue)
- console.clear()
- console.setCursorPos(1,1)
- console.write(" Console v0.1")
- local _,y = console.getCursorPos()
- console.setCursorPos(1,y+1)
- end
- function log(words,col,back)
- words = tostring(words)
- words = " > "..words
- col = col or colors.gray
- back = back or colors.white
- console.setTextColor(col)
- console.setBackgroundColor(back)
- console.write(words)
- local _,y = console.getCursorPos()
- console.setCursorPos(1,y+1)
- end
- clear()
- log("heres some fresh words")
- log("more stuff")
- log("even more stugf")
- log("cant keep up")
- log("have a log")
- function displayEvents()
- while true do
- local e = {os.pullEvent()} --bcuz terminating is actually gud
- if e then
- for i=2,5 do
- console.setCursorPos(1,i)
- console.clearLine()
- end
- console.setCursorPos(1,2)
- for _,v in ipairs(e) do
- log(v)
- end
- end
- end
- end
- function waitForScroll()
- local keyPress = {
- up = {200,-1},
- down = {208,1},
- }
- while true do
- local e = {os.pullEvent()}
- local x,y = console.getCursorPos()
- local h = fs.open("trp","a")
- h.writeLine(x," ",y)
- h.close()
- if e[1] == "mouse_scroll" or "key" then
- for i=1,2 do
- if e[2] == keyPress.up[i] and y~=1 then
- console.scroll(1)
- elseif e[2] == keyPress.down[i] and y~=h then
- console.scroll(-1)
- end
- end
- end
- end
- end
- fs.open("trp","w")
- waitForScroll()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement