Advertisement
TheOddByte

[ComputerCraft][Program]TerMonitor

Dec 21st, 2013
1,280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.55 KB | None | 0 0
  1. --[[
  2.     [Program] TerMonitor
  3.     @version 1.0, 21/12/2013, "BSoD"
  4.     @author Hellkid98, HK98
  5. --]]
  6.  
  7. local monitors = {}
  8. --# Getting all the monitors attached
  9. for _, name in ipairs(peripheral.getNames()) do
  10.     if peripheral.getType( name ) == "monitor" then
  11.         local nMon = {}
  12.         nMon.name = name
  13.         table.insert(monitors, nMon)
  14.     end
  15. end
  16.  
  17. --# Wrapping the monitors
  18. local w, h = term.getSize()
  19. for i = 1,#monitors do
  20.     monitors[i].name = peripheral.wrap(monitors[i].name)
  21.     monitors[i]["name"].setTextScale(0.5)
  22.     for scale = 1, 5, 0.5 do
  23.         monitors[i]["name"].setTextScale( scale )
  24.         local mW, mH = monitors[i]["name"].getSize()
  25.         if mW < w or mH < h then
  26.             monitors[i]["name"].setTextScale( scale - 0.5 )
  27.             break
  28.         end
  29.     end
  30. end
  31.  
  32.  
  33.  
  34.  
  35. term_write = term_write or term.write
  36. term.write = function( text )
  37.     term_write( text )
  38.     for i = 1,#monitors do
  39.         monitors[i]["name"].write( text )
  40.     end
  41. end
  42.  
  43.  
  44. term_setCursorPos = term_setCursorPos or term.setCursorPos
  45. term.setCursorPos = function( x, y )
  46.     term_setCursorPos( x, y )
  47.     for i = 1,#monitors do
  48.         monitors[i]["name"].setCursorPos( x, y )
  49.     end
  50. end
  51.  
  52.  
  53. term_clear = term_clear or term.clear
  54. term.clear = function()
  55.     term_clear()
  56.     for i = 1,#monitors do
  57.         monitors[i]["name"].clear()
  58.     end
  59. end
  60.  
  61.  
  62. term_clearLine = term_clearLine or term.clearLine
  63. term.clearLine = function()
  64.     term_clearLine()
  65.     for i = 1,#monitors do
  66.         monitors[i]["name"].clearLine()
  67.     end
  68. end
  69.  
  70.  
  71. term_setCursorBlink = term_setCursorBlink or term.setCursorBlink
  72. term.setCursorBlink = function( boolean )
  73.     term_setCursorBlink( boolean )
  74.     for i = 1,#monitors do
  75.         monitors[i]["name"].setCursorBlink( boolean )
  76.     end
  77. end
  78.  
  79.  
  80. term_scroll = term_scroll or term.scroll
  81. term.scroll = function( num )
  82.     term_scroll( num )
  83.     for i = 1,#monitors do
  84.         monitors[i]["name"].scroll( num )
  85.     end
  86. end
  87.  
  88.  
  89. term_setTextColor = term_setTextColor or term.setTextColor
  90. term.setTextColor = function( color )
  91.     term_setTextColor( color )
  92.     for i = 1,#monitors do
  93.         monitors[i]["name"].setTextColor( color )
  94.     end
  95. end
  96. term.setTextColour = term.setTextColor
  97.  
  98.  
  99. term_setBackgroundColor = term_setBackgroundColor or term.setBackgroundColor
  100. term.setBackgroundColor = function( color )
  101.     term_setBackgroundColor( color )
  102.     for i = 1, #monitors do
  103.         monitors[i]["name"].setBackgroundColor( color )
  104.     end
  105. end
  106. term.setBackgroundColour = term.setBackgroundColor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement