DubSlime

DubTimer/execute (Terminal Edition)

Oct 6th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.23 KB | None | 0 0
  1. -- DubTimer - Copyright DubSlime 2015 --
  2. -- Produit non distribuable --
  3. -- Pour toutes informations, contacter DubSlime --
  4. -- Toute copie est strictement interdite --
  5. -- L'utilisation de ce programme doit etre --
  6. -- accompagnee des credits de l'auteur --
  7.  
  8. -- ESPACE MISE A JOUR ----------
  9. if not fs.exists("DubTimer/menu") then
  10. shell.run("pastebin get rDfP20ye menu")
  11. fs.move("menu", "DubTimer/menu")
  12. end
  13. if not fs.exists("DubTimer/home") then
  14. shell.run("pastebin get QnzdGZwh home")
  15. fs.move("home", "DubTimer/home")
  16. end
  17. if not fs.exists("DubTimer/home.paint") then
  18. shell.run("pastebin get siWAWmZg home.paint")
  19. fs.move("home.paint", "DubTimer/home.paint")
  20. end
  21. --------------------------------
  22.  
  23. --- MISE EN PAGE - AFFICHAGE ---
  24. function draw(BColor, TColor, Xcord, Ycord, text)
  25. term.setCursorPos(Xcord, Ycord)
  26. term.setBackgroundColor(colours[BColor])
  27. term.setTextColor(colours[TColor])
  28. term.write(text)
  29. term.setBackgroundColor(colours.grey)
  30. end
  31. shell.run("DubTimer/config1")
  32. shell.run("DubTimer/config2")
  33. shell.run("monitor "..monSide.." DubTimer/home")
  34. rs.setOutput("front", false)
  35. rs.setBundledOutput(cableSide, 0)
  36. term.clear()
  37. fois = 0
  38. impt = 0
  39. menu = false
  40. impc = 0
  41. imps = false
  42. total = 0
  43. tps = 0
  44. temps = 0
  45. etat = 0
  46. cable = "white"
  47. function screen()
  48. mon = peripheral.wrap(monSide)
  49. term.setBackgroundColor(colours.grey)
  50. term.clear()
  51. term.setBackgroundColor(colours.orange)
  52. term.setCursorPos(1,1)
  53. term.clearLine()
  54. draw("orange", "white", 1, 1, "Impulsion dans : ")
  55. draw("orange", "white", 18, 1, "X")
  56. draw("white", "red", 2, 3, "---")
  57. draw("white", "red", 6, 3, "--")
  58. draw("white", "red", 9, 3, "-")
  59. draw("lightGrey", "white", 1, 2, " Temps entre impulsion ")
  60. draw("white", "lime", 21, 3, "+")
  61. draw("white", "lime", 23, 3, "++")
  62. draw("white", "lime", 26, 3, "+++")
  63. draw("lightGrey", "white", 1, 5, " Temps total ")
  64. draw("white", "red", 2, 6, "---")
  65. draw("white", "red", 6, 6, "--")
  66. draw("white", "red", 9, 6, "-")
  67. draw("white", "lime", 21, 6, "+")
  68. draw("white", "lime", 23, 6, "++")
  69. draw("white", "lime", 26, 6, "+++")
  70. draw("lightGrey", "white", 2, 8, "Mouvement")
  71. term.setCursorPos(2,9)
  72. term.setBackgroundColor(colours[cable])
  73. term.write(" ")
  74. draw("lightGrey", "white", 2, 10, " Choix ")
  75. draw("yellow", "white", 2, 11, " ")
  76. draw("white", "white", 5, 11, " ")
  77. draw("magenta", "white", 8, 11, " ")
  78. draw("lightGrey", "white", 20, 8, " Impuls. ")
  79. draw("white", "white", 20, 9, " ")
  80. draw("red", "white", 20, 10, "--")
  81. draw("orange", "white", 22, 10, "--")
  82. draw("lightBlue", "white", 25, 10, "++")
  83. draw("cyan", "white", 27, 10, "++")
  84. draw("lightGrey", "white", 20, 11, " ")
  85. draw("lime", "white", 20, 11, "Val.")
  86. draw("red", "white", 25, 11, "Ref.")
  87. end
  88. --while true do
  89. function gestion()
  90. draw("blue", "white", 24, 1, " MENU ")
  91. draw("orange", "white", 18, 1, tps)
  92. if impt < 0 then
  93. impt = 0
  94. end
  95. if total < 0 then
  96. total = 0
  97. end
  98. if impc < 0 then
  99. impc = 0
  100. end
  101. if menu == false and imps == true then
  102. total = math.ceil(impt * impc)
  103. draw("blue", "grey", 24, 10, "O")
  104. elseif menu == false and imps == false then
  105. draw("red", "grey", 24, 10, "X")
  106. end
  107. draw("grey", "white", 14, 3, impt)
  108. draw("grey", "white", 14, 6, total)
  109. draw("white", "grey", 22, 9, impc)
  110. if menu == false and etat == 0 then
  111. draw("lime", "green", 12, 8, " ")
  112. draw("lime", "green", 12, 9, " START ")
  113. draw("lime", "green", 12, 10, " ")
  114. elseif menu == false and etat == 1 then
  115. draw("red", "black", 12, 8, " ")
  116. draw("red", "black", 12, 9, " STOP ")
  117. draw("red", "black", 12, 10, " ")
  118. else
  119. etat = 0
  120. end
  121. term.setCursorPos(1,1)
  122. term.setCursorPos(2,9)
  123. term.setTextColor(colours.lightGrey)
  124. if menu == false and cable == "yellow" then
  125. term.setBackgroundColor(colours[cable])
  126. term.write(" Avant ")
  127. elseif menu == false and cable == "white" then
  128. term.setBackgroundColor(colours[cable])
  129. term.write(" Arriere ")
  130. elseif menu == false and cable == "magenta" then
  131. term.setBackgroundColor(colours[cable])
  132. term.write(" Gauche ")
  133. end
  134. -- MENU --
  135. if menu == true then
  136. term.setCursorPos(1,12)
  137. shell.run("pastebin run n1yMDZsU")
  138. shell.run("DubTimer/version")
  139. img = paintutils.loadImage("DubTimer/menu")
  140. --term.redirect(mon)
  141. paintutils.drawImage(img, 1, 1)
  142. draw("orange", "white", 24, 1, " MENU ")
  143. draw("orange", "white", 1, 12, " Reboot ")
  144. -- term.restore()
  145. draw("grey", "white", 2, 3, "Version actuelle : ")
  146. if version == version2 then
  147. draw("grey", "lime", 21, 3, version2)
  148. else
  149. draw("grey", "red", 21, 3, version2)
  150. end
  151. draw("grey", "white", 2, 4, "Derniere version : "..version)
  152. draw("orange", "white", 2, 5, " Mettre a jour ")
  153. end
  154. event, side, xpos, ypos = os.pullEvent("mouse_click")
  155. if menu == false and xpos >= 6 and xpos <= 7 and ypos == 3 then
  156. impt = impt -10
  157. elseif menu == false and xpos == 9 and ypos == 3 then
  158. impt = impt -1
  159. elseif menu == false and xpos == 21 and ypos == 3 then
  160. impt = impt +1
  161. elseif menu == false and xpos >= 23 and xpos <= 24 and ypos == 3 then
  162. impt = impt +10
  163. elseif menu == false and xpos >= 6 and xpos <= 7 and ypos == 6 then
  164. total = total -10
  165. elseif menu == false and xpos == 9 and ypos == 6 then
  166. total = total -1
  167. elseif menu == false and xpos == 21 and ypos ==6 then
  168. total = total +1
  169. elseif menu == false and xpos >= 23 and xpos <= 24 and ypos == 6 then
  170. total = total +10
  171. elseif menu == false and xpos >= 2 and xpos <= 4 and ypos == 3 then
  172. impt = impt -100
  173. elseif menu == false and xpos >= 26 and xpos <= 28 and ypos == 3 then
  174. impt = impt +100
  175. elseif menu == false and xpos >= 2 and xpos <= 4 and ypos == 6 then
  176. total = total -100
  177. elseif menu == false and xpos >= 26 and xpos <= 28 and ypos == 6 then
  178. total = total +100
  179. elseif menu == false and xpos >= 2 and xpos <= 4 and ypos == 11 then
  180. cable = "yellow"
  181. -- print(" Cable : Jaune ")
  182. elseif menu == false and xpos >= 5 and xpos <= 7 and ypos == 11 then
  183. cable = "white"
  184. -- print(" Cable : Blanc ")
  185. elseif menu == false and xpos >= 8 and xpos <= 10 and ypos == 11 then
  186. cable = "magenta"
  187. -- print(" Cable : Magenta ")
  188. elseif menu == false and xpos >= 20 and xpos <= 21 and ypos == 10 then
  189. impc = impc -10
  190. elseif menu == false and xpos >= 22 and xpos <= 23 and ypos == 10 then
  191. impc = impc -1
  192. elseif menu == false and xpos >= 25 and xpos <= 26 and ypos == 10 then
  193. impc = impc +1
  194. elseif menu == false and xpos >= 27 and xpos <= 28 and ypos == 10 then
  195. impc = impc +10
  196. elseif menu == false and xpos >= 20 and xpos <= 23 and ypos == 11 then
  197. imps = true
  198. elseif menu == false and xpos >= 25 and xpos <= 28 and ypos == 11 then
  199. impc = 0
  200. imps = false
  201. elseif menu == false and xpos >= 24 and xpos <= 29 and ypos == 1 then
  202. menu = true
  203. elseif menu == true and xpos >= 24 and xpos <= 29 and ypos <= 1 then
  204. menu = false
  205. screen()
  206. elseif menu == true and xpos >= 2 and xpos <= 16 and ypos == 5 then
  207. fc = fs.open("DubTimer/majconfig", "w")
  208. fc.writeLine("AutoUpdate = true")
  209. fc.close()
  210. draw("grey", "lightGrey", 2, 5, "Telechargement...")
  211. sleep(0.5)
  212. draw("grey", "lightGrey", 2, 6, "Redemarrage...")
  213. sleep(0.5)
  214. os.reboot()
  215. elseif menu == true and xpos >= 1 and xpos <= 8 and ypos == 12 then
  216. os.reboot()
  217. elseif menu == false and xpos >= 12 and xpos <= 18 and ypos >= 9 and ypos <= 11 then
  218. if etat == 1 then
  219. etat = 0
  220. elseif etat == 0 then
  221. etat = 1
  222. tps = impt
  223. end
  224. end
  225. end
  226.  
  227. function pulse()
  228. rs.setBundledOutput(cableSide, colours[cable])
  229. sleep(0.5)
  230. rs.setBundledOutput(cableSide, 0)
  231. end
  232.  
  233. function calculs()
  234. Rst = false
  235. done = 0
  236. perc = 0
  237. temps = math.ceil(total / impt)
  238. PXLratio = 29 / 100
  239. term.setBackgroundColor(colours.grey)
  240. term.setCursorPos(1,7)
  241. term.clearLine()
  242. draw("grey", "white", 14, 11, " ")
  243. draw("white", "white", 1, 12, " ")
  244. for i=1, temps do
  245. pulse()
  246. done = done +1
  247. draw("grey", "lightBlue", 3, 7, " Progression : "..done.." / "..temps)
  248. perc = math.ceil((done / temps) *100)
  249. -- draw("purple", "white", 25, 12, " ")
  250. draw("grey", "white", 14, 11, perc.."%")
  251. -- draw("white", "white", 1, 12, " ")
  252. PXL = math.ceil(perc * PXLratio)
  253. for i=1, impt do
  254. sleep(1)
  255. tps = tps -1
  256. draw("orange", "white", 19, 1, " ")
  257. draw("orange", "white", 18, 1, tps)
  258. end
  259. BarPos = 1
  260. for i=1, PXL do
  261. draw("blue", "white", BarPos, 12, " ")
  262. BarPos = BarPos +1
  263. end
  264. tps = impt
  265. draw("orange", "white", 18, 1, impt)
  266. end
  267. end
  268.  
  269. screen()
  270.  
  271. while true do
  272. if etat == 0 then
  273. gestion()
  274. term.setBackgroundColor(colours.grey)
  275. term.setCursorPos(1,12)
  276. term.clearLine()
  277. rs.setBundledOutput(cableSide, 0)
  278. elseif etat == 1 then
  279. parallel.waitForAny(gestion, calculs)
  280. etat = 0
  281. end
  282. sleep(0.1)
  283. end
Add Comment
Please, Sign In to add comment