Advertisement
milkshake

Custom monitor program 0-0-4x

Jul 6th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.98 KB | None | 0 0
  1. -- Custom monitor program 0-0-3
  2. -- Works with: Advanced Computer & Monitor
  3. -- Environment Tested: Minecraft 1.6.4 Computer Craft version 1.5
  4. -- By RCMilkshakebunny @
  5. -- Download this file here >> http://pastebin.com/fBKRSMqN
  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. -- Monitor Center text
  57. function monCenterText(text)
  58.   local x,y = m.getSize()
  59.   local x2,y2 = m.getCursorPos()
  60.   m.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  61.   m.write(text)
  62. end
  63.  
  64. --initialise monitor function
  65. function mInit()
  66.   clearMon()
  67.   cursor(1,1)
  68.   textColor(512)
  69. end
  70.  
  71. -- ##########################
  72. -- TERMINAL FUNCTIONS -- BEGIN
  73.  
  74. -- clears terminal
  75. function clearTerm()
  76.   term.clear()
  77. end
  78.  
  79. -- writes to the terminal
  80. function writeTerm(termtext)
  81.   term.write(termtext)
  82. end
  83.  
  84. -- set terminal cursor position -- Dynamic
  85. function termCursor(p1,p2)
  86.   term.setCursorPos(p1,p2)
  87. end
  88.  
  89. -- terminal set new line
  90. function term_nl()
  91.   local _,cY= term.getCursorPos()
  92.   term.setCursorPos(1,cY+1)
  93. end
  94.  
  95. -- TERMINAL FUNCTIONS -- END
  96. -- ##########################
  97.  
  98. -- ##########################
  99. -- PAGES  BEGIN
  100.  
  101. function page1()
  102.   monitorWrite("--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--")
  103.   nl()
  104.   monitorWrite(" Welcome to the NASA Centre")
  105.   nl()
  106.   nl()
  107.   monitorWrite("  Sponsored by: @milk_corp")
  108.   nl()
  109.   monitorWrite("..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..")
  110. end
  111.  
  112. function page2()
  113.   monitorWrite("..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..")
  114.   nl()
  115.   monitorWrite(" Welcome to the NASA Centre")
  116.   nl()
  117.   nl()
  118.   monitorWrite("  Sponsored by: @milk_corp")
  119.   nl()
  120.   monitorWrite("--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--")
  121. end
  122.  
  123. function page3()
  124.   monitorWrite("--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--")
  125.   nl()
  126.   monitorWrite(" Welcome to the NASA Centre")
  127.   nl()
  128.   nl()
  129.   monitorWrite("  Sponsored by: @milk_corp")
  130.   nl()
  131.   monitorWrite("..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..")
  132. end
  133.  
  134. function page4()
  135.   monitorWrite("..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..")
  136.   nl()
  137.   monitorWrite(" Welcome to the NASA Centre")
  138.   nl()
  139.   nl()
  140.   monitorWrite("  Sponsored by: @milk_corp")
  141.   nl()
  142.   monitorWrite("--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--")
  143. end
  144.  
  145. function page5()
  146.   monitorWrite("--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--")
  147.   nl()
  148.   monitorWrite(" Welcome to the NASA Centre")
  149.   nl()
  150.   nl()
  151.   monitorWrite("  Sponsored by: @milk_corp")
  152.   nl()
  153.   monitorWrite("..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..")
  154. end
  155.  
  156. function page6()
  157.   monitorWrite("..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..")
  158.   nl()
  159.   monitorWrite(" Welcome to the NASA Centre")
  160.   nl()
  161.   nl()
  162.   monitorWrite("  Sponsored by: @milk_corp")
  163.   nl()
  164.   monitorWrite("--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--")
  165. end
  166.  
  167. function page7()
  168.   monitorWrite("--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--")
  169.   nl()
  170.   monitorWrite(" Welcome to the NASA Centre")
  171.   nl()
  172.   nl()
  173.   monitorWrite("  Sponsored by: @milk_corp")
  174.   nl()
  175.   monitorWrite("..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..")
  176. end
  177.  
  178. function page8()
  179.   monitorWrite("..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..")
  180.   nl()
  181.   monitorWrite(" Welcome to the NASA Centre")
  182.   nl()
  183.   nl()
  184.   monitorWrite("  Sponsored by: @milk_corp")
  185.   nl()
  186.   monitorWrite("--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--")
  187. end
  188.  
  189.   function leftRight()
  190.     mInit()
  191.     page1()
  192.     sleep(0.1)
  193.     mInit()
  194.     page2()
  195.     sleep(0.1)
  196.     mInit()
  197.     page3()
  198.     sleep(0.1)
  199.     mInit()
  200.     page4()
  201.     sleep(0.1)
  202.     mInit()
  203.     page5()
  204.     sleep(0.1)
  205.     mInit()
  206.     page6()
  207.     sleep(0.1)
  208.     mInit()
  209.     page7()
  210.     sleep(0.1)
  211.     mInit()
  212.     page8()
  213.     sleep(0.1)
  214.   end
  215.  
  216.   function rightLeft()
  217.     mInit()
  218.     page8()
  219.     sleep(0.1)
  220.     mInit()
  221.     page7()
  222.     sleep(0.1)
  223.     mInit()
  224.     page6()
  225.     sleep(0.1)
  226.     mInit()
  227.     page5()
  228.     sleep(0.1)
  229.     mInit()
  230.     page4()
  231.     sleep(0.1)
  232.     mInit()
  233.     page3()
  234.     sleep(0.1)
  235.     mInit()
  236.     page2()
  237.     sleep(0.1)
  238.     mInit()
  239.     page1()
  240.     sleep(0.1)
  241.   end  
  242.  
  243. -- PAGES - END
  244. -- ##########################
  245.  
  246. -- ##########################
  247. -- SCENES -- BEGIN
  248.  
  249.   function scene1()
  250.     leftRight()
  251.     rightLeft()  
  252.     leftRight()
  253.     rightLeft()
  254.     leftRight()
  255.     rightLeft()  
  256.     leftRight()
  257.     rightLeft()
  258.   end
  259.  
  260. -- SCENES -- END
  261. -- ##########################
  262.  
  263. -- the program function
  264. function program()
  265.  
  266. -- ##########################
  267. -- PROGRAM OUTPUT - BEGIN
  268.  
  269.   clearTerm()
  270.   termCursor(1,1)
  271.   writeTerm("Program Running")
  272.   term_nl()
  273.  
  274.   while true do
  275.     scene1()
  276.   end
  277.  
  278. -- Test Output to Monitor
  279. --  monitorWrite("Monitor write completed")
  280. --  nl()
  281. --  monCenterText("Centered Text")
  282. --  nl()
  283.  
  284. -- Test output to Terminal
  285. --  writeTerm("Terminal write completed")
  286. --  term_nl()
  287.  
  288. -- PROGRAM OUTPUT - END
  289. -- ##########################
  290. end
  291.  
  292. -- FUNCTIONS -- END
  293. -- ##########################
  294.  
  295. -- ############################################################
  296. -- ############################################################
  297.  
  298.  
  299. -- ##########################
  300. -- SEQUENCE -- BEGIN
  301.  
  302. mInit()
  303. program()
  304.  
  305.  
  306. -- SEQUENCE -- END
  307. -- ##########################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement