Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. local args = {...}
  2.  
  3. local Monitor = peripheral.wrap(args[1])
  4.  
  5. Monitor.clear()
  6.  
  7. local cursorX, cursorY = 0, 0
  8. Monitor.setCursorPos(cursorX, cursorY)
  9.  
  10. local cursorCurrentX, cursorCurrentY = Monitor.getCursorPos()
  11.  
  12. local function monitorWriteLine( ... ) -- writes a line and moves cursor down one
  13.  
  14. print("Starting monitorWriteLine")
  15.  
  16. local lineInc = arg[1]
  17. local text = arg[2]
  18. cursorNewPos = tonumber(cursorCurrentY) + tonumber(lineInc)
  19.  
  20. print(cursorNewPos)
  21.  
  22. Monitor.write(text)
  23. print("Written text")
  24.  
  25. Monitor.setCursorPos(cursorX, cursorNewPos)
  26. print("Set the cursor pos")
  27. end
  28.  
  29. print("Starting while loop")
  30. while true do
  31.  
  32. local event, par1, par2, par3 = os.pullEvent()
  33.  
  34. if event == "monitor_touch" then
  35. monitorWriteLine(1, "Event: " .. event)
  36. monitorWriteLine(1, "Side: " .. par1)
  37. monitorWriteLine(1, "X coord: " .. par2)
  38. monitorWriteLine(1, "Y coord: " .. par3)
  39.  
  40. elseif event == "key" then
  41.  
  42. if par1 == keys.q then
  43.  
  44. print("Quiting program")
  45. Monitor.setCursorPos(0,0)
  46. return
  47.  
  48. elseif par1 == keys.up then
  49.  
  50. Monitor.scroll(-1)
  51.  
  52. elseif par1 == keys.down then
  53.  
  54. Monitor.scroll(1)
  55.  
  56. end
  57.  
  58. else
  59.  
  60. print(event)
  61.  
  62. end
  63.  
  64. --Monitor.clear()
  65. --Monitor.setCursorPos(0,0)
  66.  
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement