svennp

ComputerCraft spAPI

May 19th, 2012
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. -- MONITOR
  2.  
  3. function redirMon(size)
  4.   if size ~= nil then
  5.     if size < 1 or size > 5 then
  6.       size = 1
  7.     end
  8.   else size = 1
  9.   end
  10.   for n,mon in pairs(rs.getSides()) do
  11.     if peripheral.getType(mon) == "monitor" then
  12.       mon = peripheral.wrap(mon)
  13.       term.redirect(mon)
  14.       mon.setTextScale(size)
  15.       break
  16.     end
  17.   end
  18. end
  19.  
  20. function restoreMon()
  21.   term.restore()
  22. end
  23.  
  24. -- REDNET
  25. function rednetOn()
  26.   for n,modem in pairs(rs.getSides()) do
  27.     if peripheral.getType(modem) == "modem" then
  28.       rednet.open(modem)
  29.     end
  30.   end
  31. end
  32.  
  33. function rednetOff()
  34.   for n,modem in pairs(rs.getSides()) do
  35.     if peripheral.getType(modem) == "modem" then
  36.       rednet.close(modem)
  37.     end
  38.   end
  39. end
  40.  
  41. -- OTHER
  42.  
  43. function cPrint(text)
  44.   x2,y2 = term.getCursorPos()
  45.   x,y = term.getSize()
  46.   term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  47.   print(text)
  48. end
  49.  
  50. function clear(n1,n2)
  51.   term.clear()
  52.   if n1 == nil then
  53.     term.setCursorPos(1,1)
  54.   elseif n1 ~= nil and n2 == nil then
  55.     term.setCursorPos(1,n1)
  56.   else
  57.     term.setCursorPos(n2,n1)
  58.   end
  59. end
Advertisement
Add Comment
Please, Sign In to add comment