Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- DubTimer - Copyright DubSlime 2015 --
- -- Produit non distribuable --
- -- Pour toutes informations, contacter DubSlime --
- -- Toute copie est strictement interdite --
- -- L'utilisation de ce programme doit etre --
- -- accompagnee des credits de l'auteur --
- -- ESPACE MISE A JOUR ----------
- if not fs.exists("DubTimer/menu") then
- shell.run("pastebin get rDfP20ye menu")
- fs.move("menu", "DubTimer/menu")
- end
- if not fs.exists("DubTimer/home") then
- shell.run("pastebin get QnzdGZwh home")
- fs.move("home", "DubTimer/home")
- end
- if not fs.exists("DubTimer/home.paint") then
- shell.run("pastebin get siWAWmZg home.paint")
- fs.move("home.paint", "DubTimer/home.paint")
- end
- --------------------------------
- --- MISE EN PAGE - AFFICHAGE ---
- function draw(BColor, TColor, Xcord, Ycord, text)
- term.setCursorPos(Xcord, Ycord)
- term.setBackgroundColor(colours[BColor])
- term.setTextColor(colours[TColor])
- term.write(text)
- term.setBackgroundColor(colours.grey)
- end
- shell.run("DubTimer/config1")
- shell.run("DubTimer/config2")
- shell.run("monitor "..monSide.." DubTimer/home")
- rs.setOutput("front", false)
- rs.setBundledOutput(cableSide, 0)
- term.clear()
- fois = 0
- impt = 0
- menu = false
- impc = 0
- imps = false
- total = 0
- tps = 0
- temps = 0
- etat = 0
- cable = "white"
- function screen()
- mon = peripheral.wrap(monSide)
- term.setBackgroundColor(colours.grey)
- term.clear()
- term.setBackgroundColor(colours.orange)
- term.setCursorPos(1,1)
- term.clearLine()
- draw("orange", "white", 1, 1, "Impulsion dans : ")
- draw("orange", "white", 18, 1, "X")
- draw("white", "red", 2, 3, "---")
- draw("white", "red", 6, 3, "--")
- draw("white", "red", 9, 3, "-")
- draw("lightGrey", "white", 1, 2, " Temps entre impulsion ")
- draw("white", "lime", 21, 3, "+")
- draw("white", "lime", 23, 3, "++")
- draw("white", "lime", 26, 3, "+++")
- draw("lightGrey", "white", 1, 5, " Temps total ")
- draw("white", "red", 2, 6, "---")
- draw("white", "red", 6, 6, "--")
- draw("white", "red", 9, 6, "-")
- draw("white", "lime", 21, 6, "+")
- draw("white", "lime", 23, 6, "++")
- draw("white", "lime", 26, 6, "+++")
- draw("lightGrey", "white", 2, 8, "Mouvement")
- term.setCursorPos(2,9)
- term.setBackgroundColor(colours[cable])
- term.write(" ")
- draw("lightGrey", "white", 2, 10, " Choix ")
- draw("yellow", "white", 2, 11, " ")
- draw("white", "white", 5, 11, " ")
- draw("magenta", "white", 8, 11, " ")
- draw("lightGrey", "white", 20, 8, " Impuls. ")
- draw("white", "white", 20, 9, " ")
- draw("red", "white", 20, 10, "--")
- draw("orange", "white", 22, 10, "--")
- draw("lightBlue", "white", 25, 10, "++")
- draw("cyan", "white", 27, 10, "++")
- draw("lightGrey", "white", 20, 11, " ")
- draw("lime", "white", 20, 11, "Val.")
- draw("red", "white", 25, 11, "Ref.")
- end
- --while true do
- function gestion()
- draw("blue", "white", 24, 1, " MENU ")
- draw("orange", "white", 18, 1, tps)
- if impt < 0 then
- impt = 0
- end
- if total < 0 then
- total = 0
- end
- if impc < 0 then
- impc = 0
- end
- if menu == false and imps == true then
- total = math.ceil(impt * impc)
- draw("blue", "grey", 24, 10, "O")
- elseif menu == false and imps == false then
- draw("red", "grey", 24, 10, "X")
- end
- draw("grey", "white", 14, 3, impt)
- draw("grey", "white", 14, 6, total)
- draw("white", "grey", 22, 9, impc)
- if menu == false and etat == 0 then
- draw("lime", "green", 12, 8, " ")
- draw("lime", "green", 12, 9, " START ")
- draw("lime", "green", 12, 10, " ")
- elseif menu == false and etat == 1 then
- draw("red", "black", 12, 8, " ")
- draw("red", "black", 12, 9, " STOP ")
- draw("red", "black", 12, 10, " ")
- else
- etat = 0
- end
- term.setCursorPos(1,1)
- term.setCursorPos(2,9)
- term.setTextColor(colours.lightGrey)
- if menu == false and cable == "yellow" then
- term.setBackgroundColor(colours[cable])
- term.write(" Avant ")
- elseif menu == false and cable == "white" then
- term.setBackgroundColor(colours[cable])
- term.write(" Arriere ")
- elseif menu == false and cable == "magenta" then
- term.setBackgroundColor(colours[cable])
- term.write(" Gauche ")
- end
- -- MENU --
- if menu == true then
- term.setCursorPos(1,12)
- shell.run("pastebin run n1yMDZsU")
- shell.run("DubTimer/version")
- img = paintutils.loadImage("DubTimer/menu")
- --term.redirect(mon)
- paintutils.drawImage(img, 1, 1)
- draw("orange", "white", 24, 1, " MENU ")
- draw("orange", "white", 1, 12, " Reboot ")
- -- term.restore()
- draw("grey", "white", 2, 3, "Version actuelle : ")
- if version == version2 then
- draw("grey", "lime", 21, 3, version2)
- else
- draw("grey", "red", 21, 3, version2)
- end
- draw("grey", "white", 2, 4, "Derniere version : "..version)
- draw("orange", "white", 2, 5, " Mettre a jour ")
- end
- event, side, xpos, ypos = os.pullEvent("mouse_click")
- if menu == false and xpos >= 6 and xpos <= 7 and ypos == 3 then
- impt = impt -10
- elseif menu == false and xpos == 9 and ypos == 3 then
- impt = impt -1
- elseif menu == false and xpos == 21 and ypos == 3 then
- impt = impt +1
- elseif menu == false and xpos >= 23 and xpos <= 24 and ypos == 3 then
- impt = impt +10
- elseif menu == false and xpos >= 6 and xpos <= 7 and ypos == 6 then
- total = total -10
- elseif menu == false and xpos == 9 and ypos == 6 then
- total = total -1
- elseif menu == false and xpos == 21 and ypos ==6 then
- total = total +1
- elseif menu == false and xpos >= 23 and xpos <= 24 and ypos == 6 then
- total = total +10
- elseif menu == false and xpos >= 2 and xpos <= 4 and ypos == 3 then
- impt = impt -100
- elseif menu == false and xpos >= 26 and xpos <= 28 and ypos == 3 then
- impt = impt +100
- elseif menu == false and xpos >= 2 and xpos <= 4 and ypos == 6 then
- total = total -100
- elseif menu == false and xpos >= 26 and xpos <= 28 and ypos == 6 then
- total = total +100
- elseif menu == false and xpos >= 2 and xpos <= 4 and ypos == 11 then
- cable = "yellow"
- -- print(" Cable : Jaune ")
- elseif menu == false and xpos >= 5 and xpos <= 7 and ypos == 11 then
- cable = "white"
- -- print(" Cable : Blanc ")
- elseif menu == false and xpos >= 8 and xpos <= 10 and ypos == 11 then
- cable = "magenta"
- -- print(" Cable : Magenta ")
- elseif menu == false and xpos >= 20 and xpos <= 21 and ypos == 10 then
- impc = impc -10
- elseif menu == false and xpos >= 22 and xpos <= 23 and ypos == 10 then
- impc = impc -1
- elseif menu == false and xpos >= 25 and xpos <= 26 and ypos == 10 then
- impc = impc +1
- elseif menu == false and xpos >= 27 and xpos <= 28 and ypos == 10 then
- impc = impc +10
- elseif menu == false and xpos >= 20 and xpos <= 23 and ypos == 11 then
- imps = true
- elseif menu == false and xpos >= 25 and xpos <= 28 and ypos == 11 then
- impc = 0
- imps = false
- elseif menu == false and xpos >= 24 and xpos <= 29 and ypos == 1 then
- menu = true
- elseif menu == true and xpos >= 24 and xpos <= 29 and ypos <= 1 then
- menu = false
- screen()
- elseif menu == true and xpos >= 2 and xpos <= 16 and ypos == 5 then
- fc = fs.open("DubTimer/majconfig", "w")
- fc.writeLine("AutoUpdate = true")
- fc.close()
- draw("grey", "lightGrey", 2, 5, "Telechargement...")
- sleep(0.5)
- draw("grey", "lightGrey", 2, 6, "Redemarrage...")
- sleep(0.5)
- os.reboot()
- elseif menu == true and xpos >= 1 and xpos <= 8 and ypos == 12 then
- os.reboot()
- elseif menu == false and xpos >= 12 and xpos <= 18 and ypos >= 9 and ypos <= 11 then
- if etat == 1 then
- etat = 0
- elseif etat == 0 then
- etat = 1
- tps = impt
- end
- end
- end
- function pulse()
- rs.setBundledOutput(cableSide, colours[cable])
- sleep(0.5)
- rs.setBundledOutput(cableSide, 0)
- end
- function calculs()
- Rst = false
- done = 0
- perc = 0
- temps = math.ceil(total / impt)
- PXLratio = 29 / 100
- term.setBackgroundColor(colours.grey)
- term.setCursorPos(1,7)
- term.clearLine()
- draw("grey", "white", 14, 11, " ")
- draw("white", "white", 1, 12, " ")
- for i=1, temps do
- pulse()
- done = done +1
- draw("grey", "lightBlue", 3, 7, " Progression : "..done.." / "..temps)
- perc = math.ceil((done / temps) *100)
- -- draw("purple", "white", 25, 12, " ")
- draw("grey", "white", 14, 11, perc.."%")
- -- draw("white", "white", 1, 12, " ")
- PXL = math.ceil(perc * PXLratio)
- for i=1, impt do
- sleep(1)
- tps = tps -1
- draw("orange", "white", 19, 1, " ")
- draw("orange", "white", 18, 1, tps)
- end
- BarPos = 1
- for i=1, PXL do
- draw("blue", "white", BarPos, 12, " ")
- BarPos = BarPos +1
- end
- tps = impt
- draw("orange", "white", 18, 1, impt)
- end
- end
- screen()
- while true do
- if etat == 0 then
- gestion()
- term.setBackgroundColor(colours.grey)
- term.setCursorPos(1,12)
- term.clearLine()
- rs.setBundledOutput(cableSide, 0)
- elseif etat == 1 then
- parallel.waitForAny(gestion, calculs)
- etat = 0
- end
- sleep(0.1)
- end
Add Comment
Please, Sign In to add comment