craniumkid22

CCU Projector

Jan 31st, 2013
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.36 KB | None | 0 0
  1. local monR = peripheral.wrap("right")
  2. local monL = peripheral.wrap("left")
  3. local monB = peripheral.wrap("bottom")
  4. local monX,monY = monB.getSize()
  5. monR.setTextScale(3.5)
  6. monL.setTextScale(3.5)
  7. monB.setTextScale(2)
  8. monL.clear()
  9. monR.clear()
  10. monB.clear()
  11.  
  12. local function monWrite(side, string, x, y, BGcolor, color)
  13.     if not color then color = colors.white end
  14.     if not BGcolor then BGcolor = colors.black end
  15.     local mon = peripheral.wrap(side)
  16.     mon.setCursorPos(x,y)
  17.     mon.setTextColor(color)
  18.     mon.setBackgroundColor(BGcolor)
  19.     mon.write(string)
  20. end
  21.  
  22. local function cPrint(side, string, y, BGcolor, color)
  23.     local x = (monX/4) - (string.len(string)/4)
  24.     monWrite(side, string, x, y, BGcolor, color)
  25. end
  26.  
  27. local function header(title)
  28.     monR.setBackgroundColor(colors.black)
  29.     monR.clear()
  30.     monR.setCursorPos(1,1)
  31.     for i = 1,2 do
  32.         monWrite("left", string.rep(" ",monX), 1, i, colors.lightBlue, colors.white)
  33.         monWrite("right", string.rep(" ",monX), 1, i, colors.lightBlue, colors.white)
  34.     end
  35.     monWrite("left", title, 1, 1, colors.lightBlue, colors.white)
  36.     monWrite("right", title, 1, 1, colors.lightBlue, colors.white)
  37. end
  38.  
  39. local function content(line, string)
  40.     monWrite("bottom", string, 1, line)
  41. end
  42.  
  43. local function getSlides(lesson)
  44.     local lessonSlides = fs.list(lesson)
  45.     local slideContent = {}
  46.     for i = 1,#lessonSlides do
  47.         local file = fs.open(lesson.."/"..i, "r")
  48.         slide = {}
  49.         repeat
  50.             local slideLine = file.readLine()
  51.             table.insert(slide, slideLine)
  52.         until slideLine == nil
  53.         table.insert(slideContent, slide)
  54.     end
  55.     return slideContent
  56. end
  57.  
  58. term.clear()
  59. term.setCursorPos(1,1)
  60. write("Lesson title: ")
  61. local lessonTitle = read()
  62. local contentLines = getSlides(lessonTitle)
  63. term.clear()
  64. term.setCursorPos(1,7)
  65. print("  /")
  66. print(" / ")
  67. print("/  ")
  68. print("\\  ")
  69. print(" \\ ")
  70. print("  \\")
  71. term.setCursorPos(48,7)
  72. write("\\  ")
  73. term.setCursorPos(48,8)
  74. write(" \\ ")
  75. term.setCursorPos(48,9)
  76. write("  \\")
  77. term.setCursorPos(48,10)
  78. write("  /")
  79. term.setCursorPos(48,11)
  80. write(" / ")
  81. term.setCursorPos(48,12)
  82. write("/  ")
  83. term.setCursorPos(1,1)
  84. write(textutils.serialize(contentLines))
  85. while true do
  86.     local events = {os.pullEvent()}
  87.     if events[1] == "mouse_click" and events[2] == 2 then
  88.         for i = 1,#contentLines do
  89.             if i == 1 then
  90.                 header(contentLines[i])
  91.             else
  92.                 content(i, contentLines[i])
  93.             end
  94.         end
  95.     end
  96. end
Advertisement
Add Comment
Please, Sign In to add comment