SHOW:
|
|
- or go back to the newest paste.
| 1 | - | local tArg = {...}
|
| 1 | + | tArg = {...}
|
| 2 | ||
| 3 | - | local textscale = 0.5 |
| 3 | + | textscale = 0.5 |
| 4 | - | local monitorName, mon |
| 4 | + | |
| 5 | function displayHelp() | |
| 6 | - | if not monIsInUse then monIsInUse = {} end
|
| 6 | + | |
| 7 | - | if type(monIsInUse) ~= "table" then monIsInUse = {} end
|
| 7 | + | |
| 8 | print("monc <monitor> -s <textscale>")
| |
| 9 | - | local function displayHelp() |
| 9 | + | |
| 10 | end | |
| 11 | ||
| 12 | function setMonFuncs() | |
| 13 | if not monIsInUse then | |
| 14 | oldRedirect = term.redirect | |
| 15 | term.redirect = function( object ) | |
| 16 | - | local function setMonFuncs() |
| 16 | + | oldRedirect(object) |
| 17 | - | if not monIsInUse[monitorName] then |
| 17 | + | oldRedirect(term.native()) |
| 18 | - | local msx,msy = mon.getSize() |
| 18 | + | |
| 19 | - | oldTermWrite = term.write |
| 19 | + | |
| 20 | - | term.write = function( text ) |
| 20 | + | monIsInUse = true |
| 21 | - | oldTermWrite( text ) |
| 21 | + | |
| 22 | - | mon.write( text ) |
| 22 | + | |
| 23 | ||
| 24 | function setRegFuncs() | |
| 25 | - | oldCursorPos = term.setCursorPos |
| 25 | + | if monIsInUse == true then |
| 26 | - | term.setCursorPos = function( x, y ) |
| 26 | + | term.redirect = oldRedirect |
| 27 | - | oldCursorPos( x, y ) |
| 27 | + | monIsInUse = false |
| 28 | - | mon.setCursorPos( x, y ) |
| 28 | + | |
| 29 | end | |
| 30 | ||
| 31 | - | oldClear = term.clear |
| 31 | + | |
| 32 | - | term.clear = function() |
| 32 | + | |
| 33 | - | oldClear() |
| 33 | + | Allsides = peripheral.getNames() |
| 34 | - | local cx,cy = mon.getCursorPos() |
| 34 | + | |
| 35 | - | for a = 1, msy do |
| 35 | + | |
| 36 | - | mon.setCursorPos(1,a) |
| 36 | + | |
| 37 | - | mon.write((" "):rep(msx))
|
| 37 | + | |
| 38 | setRegFuncs() | |
| 39 | - | mon.setCursorPos(cx,cy) |
| 39 | + | |
| 40 | - | --mon.clear() |
| 40 | + | |
| 41 | if peripheral.getType(monitorName) == "monitor" then | |
| 42 | mon = peripheral.wrap(monitorName) | |
| 43 | - | oldBlink = term.setCursorBlink |
| 43 | + | |
| 44 | - | term.setCursorBlink = function( boolean ) |
| 44 | + | |
| 45 | - | oldBlink( boolean ) |
| 45 | + | |
| 46 | - | mon.setCursorBlink( boolean ) |
| 46 | + | |
| 47 | ||
| 48 | if tArg[2] == "-s" then | |
| 49 | - | oldSetTextColor = term.setTextColour |
| 49 | + | |
| 50 | - | term.setTextColor = function( colour ) |
| 50 | + | |
| 51 | - | oldSetTextColor( colour ) |
| 51 | + | |
| 52 | - | mon.setTextColor( colour ) |
| 52 | + | |
| 53 | mon.setTextScale(tonumber(tArg[3])) | |
| 54 | else | |
| 55 | - | oldSetBackgroundColor = term.setBackgroundColour |
| 55 | + | |
| 56 | - | term.setBackgroundColor = function( bgcolu ) |
| 56 | + | |
| 57 | - | oldSetBackgroundColor( bgcolu ) |
| 57 | + | |
| 58 | - | mon.setBackgroundColor( bgcolu ) |
| 58 | + | |
| 59 | return | |
| 60 | end | |
| 61 | - | oldClearLine = term.clearLine |
| 61 | + | |
| 62 | - | term.clearLine = function() |
| 62 | + | |
| 63 | - | oldClearLine() |
| 63 | + | |
| 64 | - | local cx,cy = mon.getCursorPos() |
| 64 | + | |
| 65 | - | mon.setCursorPos(1,cy) |
| 65 | + | |
| 66 | - | mon.write((" "):rep(msx))
|
| 66 | + | |
| 67 | - | mon.setCursorPos(cx,cy) |
| 67 | + | |
| 68 | argpos = 3 | |
| 69 | mon.setTextScale(textscale) | |
| 70 | - | oldScroll = term.scroll |
| 70 | + | |
| 71 | - | term.scroll = function( scrnum ) |
| 71 | + | |
| 72 | - | oldScroll(scrnum) |
| 72 | + | |
| 73 | - | mon.scroll(scrnum) |
| 73 | + | program = tArg[progpos] |
| 74 | if tArg[progpos] == "exit" then | |
| 75 | setRegFuncs() | |
| 76 | - | oldBlit = term.blit |
| 76 | + | |
| 77 | - | term.blit = function(text,t,b) |
| 77 | + | |
| 78 | - | oldBlit(text,t,b) |
| 78 | + | |
| 79 | - | mon.blit(text,t,b) |
| 79 | + | |
| 80 | for a = argpos, #tArg do | |
| 81 | arguments = arguments .. " " .. tArg[a] | |
| 82 | - | oldIsColor = term.isColor |
| 82 | + | |
| 83 | - | term.isColor = function() |
| 83 | + | |
| 84 | - | return oldIsColor() and mon.isColor() |
| 84 | + | |
| 85 | ||
| 86 | if arguments ~= nil and arguments ~= "" then | |
| 87 | - | term.setTextColour = term.setTextColor |
| 87 | + | |
| 88 | shell.run(program .. " " .. arguments) | |
| 89 | - | term.setBackgroundColour = term.setBackgroundColor |
| 89 | + | |
| 90 | else | |
| 91 | - | monIsInUse[monitorName] = true |
| 91 | + | |
| 92 | shell.run(program) | |
| 93 | setRegFuncs() | |
| 94 | end | |
| 95 | - | local function setRegFuncs() |
| 95 | + | |
| 96 | - | if #monIsInUse > 0 then |
| 96 | + | |
| 97 | - | if monIsInUse[monitorName] == true then |
| 97 | + | |
| 98 | - | term.write = oldTermWrite |
| 98 | + | |
| 99 | - | term.setCursorPos = oldCursorPos |
| 99 | + | error("no monitor given")
|
| 100 | - | term.clear = oldClear |
| 100 | + |