Guest User

tDrive

a guest
Jun 17th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. --Check for adv monitor
  2. function advMon(a, b)
  3.   if not a.isColor() then
  4.   niceError("Please upgrade "..b.." monitor to","the \"Advanced\" version.","")
  5.   end
  6. end
  7.  
  8. --Set up two peripherals
  9. function findTperipherals(p)
  10.  s = {}
  11.   for _,v in pairs(rs.getSides()) do
  12.     if #s == 2 then break end
  13.     if peripheral.getType(v) == p then
  14.       table.insert(s, v)
  15.     end
  16.   end
  17.   return unpack( s )
  18. end
  19.  
  20. function wrapTperipherals(j, k)
  21. if k ~= nil then
  22.   MO = 2
  23.   l = peripheral.wrap(j)
  24.   advMon(l, j)
  25.   m = peripheral.wrap(k)
  26.   advMon(m, k)
  27. elseif j ~= nil then
  28.   MO = 1
  29.   l = peripheral.wrap(j)
  30.   advMon(l, j)
  31.   notes("IMPORTANT", "With a second advanced monitor","you will see more information.")
  32.   sleep(3)
  33. else
  34.   niceError("No advanced monitors attached to the computer","")
  35.   return
  36. end
  37. end
  38.  
  39.  
  40. --Center text print
  41. function cprint (t)
  42.   local x2, y2 = term.getCursorPos()
  43.   local x, y = term.getSize()
  44.   term.setCursorPos(math.ceil((x/2) - (t:len()/2)), y2)
  45.   print(t)
  46. end
  47.  
  48. --Notes
  49. function notes(te, ta, tb)
  50.   term.clear()
  51.   term.setCursorPos(1, 1)
  52.   term.setTextColor(colors.cyan)
  53.   cprint("---------========= "..te.." =========---------")
  54.   term.setCursorPos(1, 3)
  55.   term.setTextColor(colors.white)
  56.   cprint(ta)
  57.   cprint(tb)
  58.   term.setCursorPos(1, 6)
  59.   term.setTextColor(colors.cyan)
  60.   cprint("---------========= "..te.." =========---------")
  61.   term.setCursorPos(1, 8)
  62.   term.setTextColor(colors.white)
  63. end
  64.  
  65. --Header function
  66. function header(te)
  67.   term.clear()
  68.   term.setCursorPos(1, 1)
  69.   term.setTextColor(colors.cyan)
  70.   cprint("---------========= "..te.." =========---------")
  71.   term.setTextColor(colors.white)
  72. end
  73.  
  74. --Header in current Pos
  75. function headerW(te)
  76.   term.setTextColor(colors.cyan)
  77.   cprint("---------========= "..te.." =========---------")
  78.   term.setTextColor(colors.white)
  79. end
  80.  
  81. --Error Messages
  82. function niceError(Ea, Eb)
  83.   header("Error!")
  84.   term.setCursorPos(1, 3)
  85.   cprint(Ea)
  86.   cprint(Eb)
  87.   local x, y = term.getCursorPos()
  88.     if Eb == "" then
  89.     y2 = y
  90.     elseif Eb ~= "" then
  91.     y2 = y + 1
  92.     end
  93.   term.setCursorPos(1, y2)
  94.   term.setTextColor(colors.cyan)
  95.   cprint("---------========= Error! =========---------")
  96.   term.setTextColor(colors.white)
  97.   error()
  98. end
Advertisement
Add Comment
Please, Sign In to add comment