rithrin

duel

Apr 19th, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. local tArgs = {...}
  2. local sSide = {}
  3. for i,v in pairs(rs.getSides()) do
  4. sSide[v] = true
  5. end
  6. local monSide
  7. local monBig = false
  8. local termX,termY = term.getSize()
  9. local customTerm = {}
  10. local moniter
  11. local oldMon = {}
  12. if #tArgs == 1 then
  13. if sSide[tArgs[1]] then
  14. monSide = string.lower(tArgs[1])
  15. if peripheral.isPresent(monSide) and peripheral.getType(monSide) == "monitor" then
  16. for size = 1.5,0.5,-0.5 do
  17. peripheral.call(monSide,"setTextScale",size)
  18. local monX,monY = peripheral.call(monSide,"getSize")
  19. if monX >= termX and monY >= termY then
  20. monBig = true
  21. break
  22. end
  23. end
  24. end
  25. elseif string.lower(tArgs[1]) == "restore" then
  26. term.restore()
  27. return
  28. end
  29. else
  30. print("USAGE: <side> or \"restore\" ")
  31. end
  32. local function wrap( _sFunction )
  33. return function( ... )
  34. peripheral.call(monSide,_sFunction,...)
  35. return oldMon[_sFunction](...)
  36. end
  37. end
  38. if monBig then
  39. moniter = peripheral.wrap(monSide)
  40. for k,v in pairs(term.native) do
  41. oldMon[k] = v
  42. end
  43. for k,v in pairs( term.native ) do
  44. if type( k ) == "string" and type( v ) == "function" then
  45. customTerm[k] = wrap(k)
  46. end
  47. end
  48. term.redirect(customTerm)
  49. term.clear()
  50. term.setCursorPos(1,1)
  51. print("Running on monitor")
  52. else
  53. print("Monitor to small")
  54. end
Advertisement
Add Comment
Please, Sign In to add comment