Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- local Monitor = peripheral.wrap(args[1])
- Monitor.clear()
- local cursorX, cursorY = 0, 0
- Monitor.setCursorPos(cursorX, cursorY)
- local cursorCurrentX, cursorCurrentY = Monitor.getCursorPos()
- local function monitorWriteLine( ... ) -- writes a line and moves cursor down one
- print("Starting monitorWriteLine")
- local lineInc = arg[1]
- local text = arg[2]
- cursorNewPos = tonumber(cursorCurrentY) + tonumber(lineInc)
- print(cursorNewPos)
- Monitor.write(text)
- print("Written text")
- Monitor.setCursorPos(cursorX, cursorNewPos)
- print("Set the cursor pos")
- end
- print("Starting while loop")
- while true do
- local event, par1, par2, par3 = os.pullEvent()
- if event == "monitor_touch" then
- monitorWriteLine(1, "Event: " .. event)
- monitorWriteLine(1, "Side: " .. par1)
- monitorWriteLine(1, "X coord: " .. par2)
- monitorWriteLine(1, "Y coord: " .. par3)
- elseif event == "key" then
- if par1 == keys.q then
- print("Quiting program")
- Monitor.setCursorPos(0,0)
- return
- elseif par1 == keys.up then
- Monitor.scroll(-1)
- elseif par1 == keys.down then
- Monitor.scroll(1)
- end
- else
- print(event)
- end
- --Monitor.clear()
- --Monitor.setCursorPos(0,0)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement