LDShadowLord

PRNT.API

Oct 25th, 2013
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Printing Program/API by LDShadowLord
  2. --Function Descriptions:
  3. --Prepare: Setup function
  4. --GetCP  : Finds the Cursor Pos
  5. --(L,C,R) Print  : print Left, Print Center, Print Right
  6. --Extra  : nullVoid
  7.  
  8. --Setting Variables
  9. local ver = 1.1
  10. local side = "right"
  11. local cons = 1
  12. local kons = 1
  13.  
  14. --Local Functions
  15. local function prepare()
  16.   p = peripheral.wrap(side)
  17.   p.newPage()
  18.   p.setPageTitle(tostring(kons))
  19.   kons = kons + 1
  20. end
  21.  
  22. local function inc()
  23.   local vx, vy = p.getCursorPos()
  24.   local vw, vh = p.getPageSize()
  25.   cons = vy + 1
  26.   if cons == 20 then
  27.     p.setCursorPos(1,21)
  28.     p.write("     PRNT API // V1.1")
  29.     p.endPage()
  30.     p.newPage()
  31.     cons = 1
  32.     p.setPageTitle(tostring(kons))
  33.     kons = kons + 1
  34.   end
  35. end
  36.  
  37. --Global Functions
  38. function setup()
  39.   prepare()
  40.   local vx, vy = p.getCursorPos()
  41.   local vw, vh = p.getPageSize()
  42. end
  43.  
  44. function title(name)
  45.   p.setPageTitle(name)
  46. end
  47.  
  48. function lPrint(text)
  49.   p.write(text)
  50.   inc()
  51.   p.setCursorPos(1,cons)
  52. end
  53.  
  54. function cPrint(text)
  55.   local vx, vy = p.getCursorPos()
  56.   local vw, vh = p.getPageSize()
  57.   vl = #text
  58.   myvx = (vw + 1) / 2
  59.   myvxx = math.ceil(myvx - (vl / 2))
  60.   term.setCursorPos(myvxx, cons)
  61.   lPrint(text)
  62. end
  63.  
  64. function rPrint(text)
  65.   local vx, vy = p.getCursorPos()
  66.   local vw, vh = p.getPageSize()
  67.   vl = #text
  68.   myvx = 24 - vl
  69.   term.setCursorPos(myvx, cons)
  70.   lPrint(text)
  71. end
  72.  
  73. function endmain()
  74.   p.setCursorPos(1,21)
  75.   p.write("     PRNT API // V1.1")
  76.   p.endPage()
  77. end
Advertisement
Add Comment
Please, Sign In to add comment