Advertisement
milkshake

Untitled

Jun 17th, 2015
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.59 KB | None | 0 0
  1. -- Custom monitor program
  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.  
  6. -- ##########################
  7. -- DEFINE VARIABLES -- BEGIN
  8.  
  9. -- Define peripheral monitor side
  10. m = peripheral.wrap("top")
  11.  
  12. -- DEFINE VARIABLES -- END
  13. -- ##########################
  14.  
  15. -- ##########################
  16. -- FUNCTIONS - BEGIN
  17.  
  18. -- set the cursor position on the monitor ready to write
  19. -- in this case 1,1 means the first line at the first character. so for western based code that would be TOP,LEFT
  20. -- 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
  21. -- in this case the function requires the value to be given in the call
  22. function cursor(p1,p2)
  23.   m.setCursorPos(p1,p2)
  24. end
  25.  
  26. -- clear any content on the monitor function
  27. function clearMon()
  28.   m.clear()
  29. end
  30.  
  31. -- set text color function
  32. function textColor(setTo)
  33. -- set the color the text will be
  34. -- in this case blue
  35. -- the choices: white | orange | magenta | lightBlue | yellow | lime | pink | gray
  36. --   contd.. | lightGray | cyan | purple | blue | brown | green | red | black
  37. -- you can also reference colors by a 'decimal value' without the requirement of the use of 'colors'
  38. -- an example of referencing a color for text by decimal is
  39. -- m.setTextColor(512) and this would produce the same result as m.setTextColor(colors.cyan)
  40. -- m.setTextColor(colors.blue) -- << basic usage
  41.   m.setTextColor(setTo)-- << dynamic usage
  42. end
  43.  
  44. -- write to monitor function
  45. function monitorWrite(txt)
  46.   m.write(txt)
  47. end
  48.  
  49. --initialise monitor function
  50. function mInit()
  51.   clearMon()
  52.   cursor(1,1)
  53.   textColor(512)
  54. end
  55.  
  56. -- ##########################
  57. -- TERMINAL FUNCTIONS -- BEGIN
  58.  
  59. -- clears terminal
  60. function clearTerm()
  61.   term.clear()
  62. end
  63.  
  64. -- writes to the terminal
  65. function writeTerm(termtext)
  66.   term.write(termtext)
  67. end
  68.  
  69. -- set terminal cursor position -- Dynamic
  70. function termCursor(p1,p2)
  71.   term.setCursorPos(p1,p2)
  72. end
  73.  
  74. -- TERMINAL FUNCTIONS -- END
  75. -- ##########################
  76.  
  77.  
  78. -- FUNCTIONS -- END
  79. -- ##########################
  80.  
  81.  
  82. -- the program function
  83. function program()
  84.  
  85. -- ##########################
  86. -- PROGRAM OUTPUT - BEGIN
  87.  
  88.   clearTerm()
  89.   writeTerm("Program Running")
  90.  
  91. -- Test Output to monitor
  92.   monitorWrite("Testing")
  93.   writeTerm("Monitor write completed")
  94.  
  95. -- PROGRAM OUTPUT - END
  96. -- ##########################
  97. end
  98.  
  99. -- ##########################
  100. -- SEQUENCE -- BEGIN
  101.  
  102. mInit()
  103. program()
  104.  
  105. -- SEQUENCE -- END
  106. -- ##########################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement