SHARE
TWEET

startup.lua

a guest May 20th, 2019 166 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local monitors = {peripheral.find("monitor")}
  2. local entry = {}
  3. repeat
  4.     term.setTextColor(colors.white)
  5.     term.clear()
  6.     term.setCursorPos(1,1)
  7.     print("Insert SCP ID")
  8.     scp = read()
  9.     if fs.exists("SCP-" .. scp) == false then
  10.         term.setTextColor(colors.red)
  11.         print("")
  12.         print("File Not Found!")
  13.         sleep(1)
  14.     end
  15. until fs.exists("SCP-" .. scp)
  16. local filename = "SCP-" .. scp
  17. local file = fs.open(filename,"r")
  18. local length = fs.getSize(filename)
  19. for curline = 1, length do
  20.     table.insert(entry,file.readLine())
  21. end
  22. local scrollMax = #entry - 20
  23. monitors[1].clear()
  24. monitors[2].clear()
  25. monitors[1].setCursorPos(1,1)
  26. monitors[2].setCursorPos(1,1)
  27. monitors[1].setTextScale(0.5)
  28. monitors[2].setTextScale(0.5)
  29. pos = 0
  30. local redraw = true
  31. local max = 27
  32. function display()
  33.     while true do
  34.         sleep(.05)
  35.         if redraw then
  36.           redraw = false
  37.  --         monitors[1].clear()
  38.         for curm = 1,2 do
  39.             curline2 = 0
  40.             repeat
  41. --        monitors[curm].clearLine(curline2+1)
  42.             --repeat
  43.                 curline2 = curline2 + 1
  44.                 monitors[curm].setCursorPos(1, curline2 + 1)
  45.                 monitors[curm].clearLine(curline2 + 1)
  46.                 monitors[curm].setCursorPos(1,curline2 +  1)
  47.                 if entry[curline2 + pos] ~= nil then
  48.             local l = entry[curline2 + pos]
  49.             local c = tonumber(l:sub(#l, #l))
  50.             local cs = {
  51.              [ 1 ] = colors.white,
  52.              [2] = colors.red,
  53.              
  54.              [3] = colors.green,
  55.              [4] = colors.cyan,
  56.              }
  57.              c = cs[c] or colors.black
  58.              monitors[curm].setTextColor(c)
  59.              
  60.           l = l:sub(1,#l - 1)        
  61.            
  62.                    
  63.                     monitors[curm].write(l)
  64.                     else
  65.                     write(" ")
  66.                 end
  67.                 m1x1, m1y1 = monitors[curm].getSize()
  68.                 monitors[curm].write((" "):rep(max - m1x1))
  69.             until curline2 == 20
  70.         end
  71.         end
  72.     end
  73. end
  74. function control()
  75.     sleep(1)
  76.     while true do
  77.         local _, _2, x, y = os.pullEvent("monitor_touch")
  78.         if y >= m1y1 / 2 then
  79.             if pos <= scrollMax then
  80.                 pos = pos + 1
  81.             end
  82.         else
  83.             if pos ~= 0 then
  84.                 pos = pos - 1
  85.             end
  86.         end
  87.         redraw = true
  88.     end
  89. end
  90. for temp = 1, 2 do
  91.     monitors[temp].setCursorPos(1,1)
  92.     monitors[temp].setTextColor(colors.gray)
  93.     monitors[temp].write("-------------------------------------")
  94.     monitors[temp].setCursorPos(1,22)
  95.     monitors[temp].write("-------------------------------------")
  96.     monitors[temp].setTextColor(colors.white)
  97. end
  98. parallel.waitForAll(control,display)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top