Advertisement
milkshake

Custom monitor program CC 0.0.2

Jun 17th, 2015
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.07 KB | None | 0 0
  1. -- Custom monitor program 0-0-2
  2. -- Works with: Advanced Computer & Monitor
  3. -- Environment Tested: Minecraft 1.6.4 Computer Craft version 1.5
  4. -- By RCMilkshakebunny @ www.rcftb.eu
  5. -- Download this file here >> http://pastebin.com/XL59sEqU
  6.  
  7. -- ##########################
  8. -- DEFINE VARIABLES -- BEGIN
  9.  
  10. -- Define peripheral monitor side
  11. m = peripheral.wrap("top")
  12.  
  13. -- DEFINE VARIABLES -- END
  14. -- ##########################
  15.  
  16. -- ##########################
  17. -- FUNCTIONS - BEGIN
  18.  
  19. -- set the cursor position on the monitor ready to write
  20. -- in this case 1,1 means the first line at the first character. so for western based code that would be TOP,LEFT
  21. -- if we were to put (5,10) then the cursor would begin at the 5th line down and the 10th character position in from the left
  22. -- in this case the function requires the value to be given in the call
  23. function cursor(p1,p2)
  24.   m.setCursorPos(p1,p2)
  25. end
  26.  
  27. -- clear any content on the monitor function
  28. function clearMon()
  29.   m.clear()
  30. end
  31.  
  32. -- set text color function
  33. function textColor(setTo)
  34. -- set the color the text will be
  35. -- in this case blue
  36. -- the choices: white | orange | magenta | lightBlue | yellow | lime | pink | gray
  37. --   contd.. | lightGray | cyan | purple | blue | brown | green | red | black
  38. -- you can also reference colors by a 'decimal value' without the requirement of the use of 'colors'
  39. -- an example of referencing a color for text by decimal is
  40. -- m.setTextColor(512) and this would produce the same result as m.setTextColor(colors.cyan)
  41. -- m.setTextColor(colors.blue) -- << basic usage
  42.   m.setTextColor(setTo)-- << dynamic usage
  43. end
  44.  
  45. -- write to monitor function
  46. function monitorWrite(txt)
  47.   m.write(txt)
  48. end
  49.  
  50. -- monitor set new line
  51. function nl()
  52.   local _,cY= m.getCursorPos()
  53.   m.setCursorPos(1,cY+1)
  54. end
  55.  
  56. --initialise monitor function
  57. function mInit()
  58.   clearMon()
  59.   cursor(1,1)
  60.   textColor(512)
  61. end
  62.  
  63. -- ##########################
  64. -- TERMINAL FUNCTIONS -- BEGIN
  65.  
  66. -- clears terminal
  67. function clearTerm()
  68.   term.clear()
  69. end
  70.  
  71. -- writes to the terminal
  72. function writeTerm(termtext)
  73.   term.write(termtext)
  74. end
  75.  
  76. -- set terminal cursor position -- Dynamic
  77. function termCursor(p1,p2)
  78.   term.setCursorPos(p1,p2)
  79. end
  80.  
  81. -- terminal set new line
  82. function term_nl()
  83.   local _,cY= term.getCursorPos()
  84.   term.setCursorPos(1,cY+1)
  85. end
  86.  
  87. -- TERMINAL FUNCTIONS -- END
  88. -- ##########################
  89.  
  90. -- the program function
  91. function program()
  92.  
  93. -- ##########################
  94. -- PROGRAM OUTPUT - BEGIN
  95.  
  96.   clearTerm()
  97.   termCursor(1,1)
  98.   writeTerm("Program Running")
  99.   term_nl()
  100.  
  101. -- Test Output to Monitor
  102.   monitorWrite("Monitor write completed")
  103. -- Test output to Terminal
  104.   writeTerm("Terminal write completed")
  105.  
  106. -- PROGRAM OUTPUT - END
  107. -- ##########################
  108. end
  109.  
  110. -- FUNCTIONS -- END
  111. -- ##########################
  112.  
  113. -- ############################################################
  114. -- ############################################################
  115.  
  116. -- ##########################
  117. -- SEQUENCE -- BEGIN
  118.  
  119. mInit()
  120. program()
  121.  
  122. -- SEQUENCE -- END
  123. -- ##########################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement