alexhorner

Display Driver

Jul 1st, 2017
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.79 KB | None | 0 0
  1. --Quartz OS Display Driver
  2.  
  3. peripherals = peripheral.getNames()
  4. monitor_names = {}
  5. monitors = {}
  6. available = true
  7. nterm = term.native()
  8.  
  9. for i = 1,#peripherals do
  10.     if peripheral.getType(peripherals[i]) == "monitor" then
  11.         table.insert(monitor_names, peripherals[i])
  12.     end
  13. end
  14.  
  15. for z = 1,#monitor_names do
  16.     table.insert(monitors, peripheral.wrap(monitor_names[z]))
  17. end
  18.  
  19. if #monitors == 0 then available = false end
  20.  
  21. function clear()
  22.     nterm.clear()
  23.     if available then
  24.         for v = 1,#monitors do
  25.             monitors[v].clear()
  26.         end
  27.     end
  28. end
  29.  
  30. function setBackgroundColour(colour)--For the British
  31.     nterm.setBackgroundColour(colour)
  32.     if available then
  33.         for v = 1,#monitors do
  34.             monitors[v].setBackgroundColour(colour)
  35.         end
  36.     end
  37. end
  38.  
  39. function setBackgroundColor(color)--For the Americans
  40.     setBackgroundColour(color)
  41. end
  42.  
  43. function setTextColour(colour)--For the British
  44.     nterm.setTextColour(colour)
  45.     if available then
  46.         for v = 1,#monitors do
  47.             monitors[v].setTextColour(colour)
  48.         end
  49.     end
  50. end
  51.  
  52. function setTextColor(color)--For the Americans
  53.     setTextColour(color)
  54. end
  55.  
  56. function setCursorPos(x, y)
  57.     nterm.setCursorPos(x, y)
  58.     if available then
  59.         for v = 1,#monitors do
  60.             monitors[v].setCursorPos(x, y)
  61.         end
  62.     end
  63. end
  64.  
  65. function setCursorBlink(blink)
  66.     nterm.setCursorBlink(blink)
  67.     if available then
  68.         for v = 1,#monitors do
  69.             monitors[v].setCursorBlink(blink)
  70.         end
  71.     end
  72. end
  73.  
  74. function blit(text, textColour, backgroundColour)
  75.     nterm.blit(text, textColour, backgroundColour)
  76.     if available then
  77.         for v = 1,#monitors do
  78.             monitors[v].blit(text, textColour, backgroundColour)
  79.         end
  80.     end
  81. end
  82.  
  83. function write(text)
  84.     nterm.write(text)
  85.     if available then
  86.         for v = 1,#monitors do
  87.             monitors[v].write(text)
  88.         end
  89.     end
  90. end
  91.  
  92. function clearLine()
  93.     nterm.clearLine()
  94.     if available then
  95.         for v = 1,#monitors do
  96.             monitors[v].clearLine()
  97.         end
  98.     end
  99. end
  100.  
  101. function getCursorPos()
  102.     return nterm.getCursorPos()
  103. end
  104.  
  105. function isColour()--For the British
  106.     return nterm.isColour()
  107. end
  108.  
  109. function isColor()--For the Americans
  110.     return nterm.isColor()
  111. end
  112.  
  113. function getSize()
  114.     return nterm.getSize()
  115. end
  116.  
  117. function scroll(lines)
  118.     nterm.scroll(lines)
  119.     if available then
  120.         for v = 1,#monitors do
  121.             monitors[v].scroll(lines)
  122.         end
  123.     end
  124. end
  125.  
  126. function redirect(destination)--Nullify
  127.     return nterm.redirect(destination)
  128. end
  129.  
  130. function current()
  131.     return nterm.current()
  132. end
  133.  
  134. function native()
  135.     return nterm.native()
  136. end
  137.  
  138. function getTextColour()--For the British
  139.     return nterm.getTextColour()
  140. end
  141.  
  142. function getTextColor()--For the Americans
  143.     return nterm.getTextColor()
  144. end
  145.  
  146. function getBackgroundColour()--For the British
  147.     return nterm.getBackgroundColour()
  148. end
  149.  
  150. function getBackgroundColor()--For the Americans
  151.     return nterm.getBackgroundColor()
  152. end
Advertisement
Add Comment
Please, Sign In to add comment