Advertisement
milkshake

Untitled

Jul 20th, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.63 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. function line1()
  72. m.write("SERVER MIGRATING/MOVING")
  73. nl()
  74. m.write("GO HERE TO FIND NEW IP ADDRESS!")
  75. nl()
  76. m.write("https://goo.gl/yNeu8p")
  77. nl()
  78. nl()
  79. m.write("Your items along with the worlds are all backed up and will be present on the new server")
  80. nl()
  81. m.write("Thanks for your patience :)")
  82. nl()
  83. m.write("@Milk")
  84. end
  85.  
  86. -- ##########################
  87. -- TERMINAL FUNCTIONS -- BEGIN
  88.  
  89. -- clears terminal
  90. function clearTerm()
  91. term.clear()
  92. end
  93.  
  94. -- writes to the terminal
  95. function writeTerm(termtext)
  96. term.write(termtext)
  97. end
  98.  
  99. -- set terminal cursor position -- Dynamic
  100. function termCursor(p1,p2)
  101. term.setCursorPos(p1,p2)
  102. end
  103.  
  104. -- terminal set new line
  105. function term_nl()
  106. local _,cY= term.getCursorPos()
  107. term.setCursorPos(1,cY+1)
  108. end
  109.  
  110. -- TERMINAL FUNCTIONS -- END
  111. -- ##########################
  112.  
  113. -- ##########################
  114. -- PAGES BEGIN
  115.  
  116. function page1()
  117. monitorWrite("--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--")
  118. nl()
  119. line1()
  120. nl()
  121. nl()
  122. monitorWrite("..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..")
  123. end
  124.  
  125. function page2()
  126. monitorWrite("..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..")
  127. nl()
  128. line1()
  129. nl()
  130. nl()
  131. monitorWrite("--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--")
  132. end
  133.  
  134. function page3()
  135. monitorWrite("--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--")
  136. nl()
  137. line1()
  138. nl()
  139. nl()
  140. monitorWrite("..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..")
  141. end
  142.  
  143. function page4()
  144. monitorWrite("..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..")
  145. nl()
  146. line1()
  147. nl()
  148. nl()
  149. monitorWrite("--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--")
  150. end
  151.  
  152. function page5()
  153. monitorWrite("--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--")
  154. nl()
  155. line1()
  156. nl()
  157. nl()
  158. monitorWrite("..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..")
  159. end
  160.  
  161. function page6()
  162. monitorWrite("..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..")
  163. nl()
  164. line1()
  165. nl()
  166. nl()
  167. monitorWrite("--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--")
  168. end
  169.  
  170. function page7()
  171. monitorWrite("--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--")
  172. nl()
  173. line1()
  174. nl()
  175. nl()
  176. monitorWrite("..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..")
  177. end
  178.  
  179. function page8()
  180. monitorWrite("..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..")
  181. nl()
  182. line1()
  183. nl()
  184. nl()
  185. monitorWrite("--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--..--")
  186. end
  187.  
  188. function leftRight()
  189. mInit()
  190. page1()
  191. sleep(0.1)
  192. mInit()
  193. page2()
  194. sleep(0.1)
  195. mInit()
  196. page3()
  197. sleep(0.1)
  198. mInit()
  199. page4()
  200. sleep(0.1)
  201. mInit()
  202. page5()
  203. sleep(0.1)
  204. mInit()
  205. page6()
  206. sleep(0.1)
  207. mInit()
  208. page7()
  209. sleep(0.1)
  210. mInit()
  211. page8()
  212. sleep(0.1)
  213. end
  214.  
  215. function rightLeft()
  216. mInit()
  217. page8()
  218. sleep(0.1)
  219. mInit()
  220. page7()
  221. sleep(0.1)
  222. mInit()
  223. page6()
  224. sleep(0.1)
  225. mInit()
  226. page5()
  227. sleep(0.1)
  228. mInit()
  229. page4()
  230. sleep(0.1)
  231. mInit()
  232. page3()
  233. sleep(0.1)
  234. mInit()
  235. page2()
  236. sleep(0.1)
  237. mInit()
  238. page1()
  239. sleep(0.1)
  240. end
  241.  
  242. -- PAGES - END
  243. -- ##########################
  244.  
  245. -- ##########################
  246. -- SCENES -- BEGIN
  247.  
  248. function scene1()
  249. leftRight()
  250. rightLeft()
  251. leftRight()
  252. rightLeft()
  253. leftRight()
  254. rightLeft()
  255. leftRight()
  256. rightLeft()
  257. end
  258.  
  259. -- SCENES -- END
  260. -- ##########################
  261.  
  262. -- the program function
  263. function program()
  264.  
  265. -- ##########################
  266. -- PROGRAM OUTPUT - BEGIN
  267.  
  268. clearTerm()
  269. termCursor(1,1)
  270. writeTerm("Program Running")
  271. term_nl()
  272.  
  273. while true do
  274. scene1()
  275. end
  276.  
  277. -- Test Output to Monitor
  278. -- monitorWrite("Monitor write completed")
  279. -- nl()
  280. -- monCenterText("Centered Text")
  281. -- nl()
  282.  
  283. -- Test output to Terminal
  284. -- writeTerm("Terminal write completed")
  285. -- term_nl()
  286.  
  287. -- PROGRAM OUTPUT - END
  288. -- ##########################
  289. end
  290.  
  291. -- FUNCTIONS -- END
  292. -- ##########################
  293.  
  294. -- ############################################################
  295. -- ############################################################
  296.  
  297.  
  298. -- ##########################
  299. -- SEQUENCE -- BEGIN
  300.  
  301. mInit()
  302. program()
  303.  
  304.  
  305. -- SEQUENCE -- END
  306. -- ##########################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement