Smiley43210

Announcements

Apr 7th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.65 KB | None | 0 0
  1. --Config options
  2. local monitorSide = "top"
  3. local MtextScale = 1
  4. local Tcolor = colors.blue
  5. local Bcolor = colors.black
  6. local topLabel = "Announcements"
  7.  
  8. --Don't touch anything below this line!
  9. local monitor = peripheral.wrap(monitorSide)
  10. monitor.setTextScale(MtextScale)
  11. monitor.setTextColor(Tcolor)
  12. monitor.setBackgroundColor(Bcolor)
  13. term.setTextColor(Tcolor)
  14. term.setBackgroundColor(Bcolor)
  15. term.clear()
  16. term.setCursorPos(1, 1)
  17. monitor.clear()
  18. monitor.setCursorPos(1, 1)
  19. term.redirect(monitor)
  20. print(topLabel)
  21. term.restore()
  22. print(topLabel)
  23.  
  24. function doPrint(text)
  25.     if text == nil then
  26.         term.redirect(monitor)
  27.         print()
  28.         term.restore()
  29.         print()
  30.     else
  31.         term.redirect(monitor)
  32.         print(text)
  33.         term.restore()
  34.         print(text)
  35.     end
  36. end
  37.  
  38. doPrint()
  39. doPrint("Loading notes...")
  40. local delay
  41. if math.random(1,2) == 2 then delay = math.random(1, 4) / math.random(2, 3) else delay = math.random(1, 4) end
  42.  
  43. sleep(delay)
  44. local handle = fs.open("notes", "r")
  45. local compiled = ""
  46. local first = true
  47. while true do
  48.     local notes = handle.readLine()
  49.     if notes == nil then break end
  50.     if first == false then compiled = compiled.."\n" end
  51.     compiled = compiled..notes
  52.     first = false
  53. end
  54. monitor.setCursorPos(1, 3)
  55. term.setCursorPos(1, 3)
  56. doPrint("Notes loaded from notefile:")
  57. doPrint("-------------------------------------")
  58. monitor.setTextColor(colors.white)
  59. term.setTextColor(colors.white)
  60. doPrint(compiled)
  61. monitor.setTextColor(Tcolor)
  62. term.setTextColor(Tcolor)
  63. doPrint("-------------------------------------")
  64. doPrint("End of notes")
  65. --[[
  66. x, y = monitor.getSize()
  67. monitor.setCursorPos(x-7, y)
  68. monitor.write("[Reboot]")
  69. monitor.setCursorPos(1, 10)
  70. monitor.write("x: "..x.." y: "..y)
  71. ]]
  72.  
  73. while true do
  74.     --[[monitor.setCursorBlink(true)
  75.     term.setCursorBlink(true)
  76.     event, param1, param2, param3 = os.pullEventRaw()
  77.     param1 = param1 or ""
  78.     param2 = param2 or ""
  79.     param3 = param3 or ""
  80.     print(event, ", ", param1, ", ", param2, ", ", param3)]]
  81.     input = read()
  82.     termX, termY = term.getCursorPos()
  83.     monitorX, monitorY = monitor.getCursorPos()
  84.     term.setCursorPos(1, 1)
  85.     monitor.setCursorPos(1, 1)
  86.     term.clearLine()
  87.     monitor.clearLine()
  88.     doPrint(topLabel)
  89.     term.setCursorPos(termX, termY)
  90.     monitor.setCursorPos(termX, termY)
  91.     if input == "reboot" then
  92.         print("Reboot: Are you sure? (yes/no)")
  93.         input2 = read()
  94.         if input2 == "yes" then
  95.             print("Rebooting...")
  96.             sleep(0.5)
  97.             os.reboot()
  98.         else
  99.             print("Reboot cancelled!")
  100.         end
  101.     end
  102. end
Advertisement
Add Comment
Please, Sign In to add comment