Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------------------
- -- --
- -- Crée par Thomas Bastien --
- -- --
- ---------------------------------------------------
- os.pullEvent = os.pullEventRaw
- local modem = peripheral.wrap("back")
- local modemxp = peripheral.wrap("top")
- local Action = "MenuPrincipal"
- local xp = false
- local a = 1
- local b = 59
- local c = 59
- local breakTimer = false
- function DrawMenuPrincipal()
- img = paintutils.loadImage("menu")
- paintutils.drawImage(img,1,1)
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- print("Ferme à Or")
- term.setCursorPos(41,1)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- print("Coopérative")
- term.setCursorPos(20,4)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- print("Temps Restant")
- term.setCursorPos(14,14)
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.yellow)
- print("Arrêter")
- term.setCursorPos(31,14)
- term.setBackgroundColor(colors.green)
- term.setTextColor(colors.yellow)
- print("Utiliser")
- term.setCursorPos(23,17)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- print("Mode Xp")
- term.setCursorPos(22,6)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- local aText = ""
- local bText = ""
- local cText = ""
- if a == 1 then
- a=0
- end
- if a < 10 then
- aText = "0"..a
- else
- aText = ""..a
- end
- if b < 10 then
- bText = "0"..b
- elseif b == 60 then
- bText = "0"
- else
- bText = ""..b
- end
- if c < 10 then
- cText = "0"..c
- elseif c==60 then
- cText = "0"
- else
- cText = ""..c
- end
- print(aText..":"..bText..":"..cText)
- if timerlaunch == false then
- time()
- end
- end
- function DrawMenuAdmin()
- imgadmin = paintutils.loadImage("menuadmin")
- paintutils.drawImage(imgadmin,1,1)
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- write("Menu Admin")
- term.setCursorPos(41,1)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- print("Coopérative")
- term.setCursorPos(12,5)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- print("Ferme")
- term.setCursorPos(34,5)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- print("Terminal")
- term.setCursorPos(12,9)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- print("Ouvrir")
- term.setCursorPos(12,12)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- print("Fermer")
- term.setCursorPos(34,9)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- print("Terminer")
- term.setCursorPos(35,12)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- print("Reboot")
- end
- function MenuAff()
- if Action == "MenuPrincipal" then
- shell.run("clear")
- DrawMenuPrincipal()
- elseif Action == "MenuAdmin" then
- shell.run("clear")
- DrawMenuAdmin()
- end
- end
- function time()
- term.setCursorPos(22,6)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- print("01:00:00")
- end
- timerlaunch = false
- function timer()
- while true do
- MenuAff()
- if Action == "MenuPrincipal" then
- time()
- end
- a=0
- b=59
- c=59
- while true do
- event = os.pullEvent()
- if event == "StartTimer" then
- break
- end
- end
- timerlaunch = true
- local na = a
- local nb = b
- local nc = c
- for i=na,0,-1 do
- if breakTimer == true then
- break
- end
- for j=nb,0,-1 do
- if breakTimer == true then
- break
- end
- for k=nc,0,-1 do
- if breakTimer == true then
- break
- end
- a=i
- b=j
- c=k
- local aText = ""
- local bText = ""
- local cText = ""
- if a == 1 then
- a=0
- end
- if a < 10 then
- aText = "0"..a
- else
- aText = ""..a
- end
- if b < 10 then
- bText = "0"..b
- elseif b == 60 then
- bText = "0"
- else
- bText = ""..b
- end
- if c < 10 then
- cText = "0"..c
- elseif c==60 then
- cText = "0"
- else
- cText = ""..c
- end
- if Action == "MenuPrincipal" then
- term.setCursorPos(22,6)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- print(aText..":"..bText..":"..cText)
- end
- sleep(1)
- end
- end
- end
- breakTimer = false
- timerlaunch=false
- modem.transmit(14,14,"false")
- end
- end
- function startup()
- modemxp.open(15)
- modemxp.transmit(15,15,inspect)
- Action = "MenuPrincipal"
- while true do
- event, p1, p2, p3 = os.pullEvent()
- if p2 == nil then
- else
- if event == "mouse_click" then
- term.setTextColor(colors.white)
- term.setCursorPos(1,7)
- --print("X:" ..p2.." Y:"..p3)
- if Action == "MenuPrincipal" then
- if p2 >= 30 and p2 <= 39 and p3 == 14 then
- term.setCursorPos(15, 10)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.red)
- print("Timer en fonctionnement")
- os.queueEvent("StartTimer")
- modem.transmit(14,14,"true")
- elseif p2 >= 13 and p2 <= 22 and p3 == 14 then
- breakTimer = true
- modemxp.transmit(15,15,inspect)
- xp = false
- elseif p2>= 51 and p3 == 1 then
- Action = "MenuAdmin"
- MenuAff()
- elseif p2 >= 21 and p2<= 30 and p3 == 17 then
- xp = not xp
- if xp == true then
- paintutils.drawLine(22,17,30,17,colors.black)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- term.setCursorPos(23,17)
- print("Mode Or")
- modemxp.transmit(15,15,"true")
- sleep(0.5)
- elseif xp == false then
- paintutils.drawLine(22,17,30,17,colors.black)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- term.setCursorPos(23,17)
- print("Mode Xp")
- modemxp.transmit(15,15,"true")
- sleep(0.5)
- end
- end
- elseif Action == "MenuAdmin" then
- if p2 >= 51 and p3 == 1 then
- Action = "MenuPrincipal"
- MenuAff()
- elseif p2 >= 7 and p2 <= 22 and p3 == 9 then
- modem.transmit(14,14,"true")
- elseif p2 >= 7 and p2 <= 22 and p3 == 12 then
- modem.transmit(14,14,"false")
- elseif p2 >= 30 and p2 <= 45 and p3 == 9 then
- Action = "Terminer"
- term.setBackgroundColor(colors.black)
- shell.run("clear")
- shell.run("shell")
- elseif p2 >= 30 and p2 <= 45 and p3 == 12 then
- os.reboot()
- end
- end
- end
- end
- end
- end
- MenuAff()
- function diskEject()
- while true do
- event, side = os.pullEvent()
- if event == "disk" then
- disk.eject(side)
- end
- end
- end
- parallel.waitForAll(startup,timer,diskEject)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement