Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ahb")
- liste={
- {
- nom="fan bleu",
- defaut=false,
- bouton=colors.lightGray,
- red=ahb.addPeripheral("hb_interupteur_11"),
- dure=40,
- delay=80,
- curs=0,
- actif=false,
- spam=false
- },
- {
- nom="piston bleu",
- defaut=false,
- bouton=colors.cyan,
- red=ahb.addPeripheral("hb_interupteur_13"),
- dure=40,
- delay=80,
- curs=0,
- actif=false,
- spam=true,
- spamVar=9
- },
- {
- nom="tapis bleu",
- defaut=true,
- bouton=colors.purple,
- red=ahb.addPeripheral("hb_interupteur_9"),
- dure=40,
- delay=80,
- curs=0,
- actif=false,
- spam=false
- },
- {
- nom="porte 1 bleu",
- defaut=false,
- bouton=colors.blue,
- red=ahb.addPeripheral("hb_interupteur_19"),
- dure=40,
- delay=80,
- curs=0,
- actif=false,
- spam=false
- },
- {
- nom="porte 2 bleu",
- defaut=false,
- bouton=colors.brown,
- red=ahb.addPeripheral("hb_interupteur_17"),
- dure=40,
- delay=80,
- curs=0,
- actif=false,
- spam=false
- },
- {
- nom="neige bleu",
- defaut=false,
- bouton=colors.green,
- red=ahb.addPeripheral("hb_interupteur_15"),
- dure=40,
- delay=80,
- curs=0,
- actif=false,
- spam=true,
- spamVar=2
- },
- {
- nom="trappe bleu",
- defaut=false,
- bouton=colors.red,
- red=ahb.addPeripheral("hb_interupteur_25"),
- dure=10,
- delay=1,
- curs=0,
- actif=false
- },
- {
- nom="fan rouge",
- defaut=false,
- bouton=colors.gray,
- red=ahb.addPeripheral("hb_interupteur_10"),
- dure=40,
- delay=80,
- curs=0,
- actif=false,
- spam=false
- },
- {
- nom="piston rouge",
- defaut=false,
- bouton=colors.pink,
- red=ahb.addPeripheral("hb_interupteur_12"),
- dure=40,
- delay=80,
- curs=0,
- actif=false,
- spam=true,
- spamVar=9
- },
- {
- nom="tapis rouge",
- defaut=true,
- bouton=colors.lime,
- red=ahb.addPeripheral("hb_interupteur_8"),
- dure=40,
- delay=80,
- curs=0,
- actif=false,
- spam=false
- },
- {
- nom="porte 1 rouge",
- defaut=false,
- bouton=colors.yellow,
- red=ahb.addPeripheral("hb_interupteur_27"),
- dure=40,
- delay=80,
- curs=0,
- actif=false,
- spam=false
- },
- {
- nom="porte 2 rouge",
- defaut=false,
- bouton=colors.lightBlue,
- red=ahb.addPeripheral("hb_interupteur_18"),
- dure=40,
- delay=80,
- curs=0,
- actif=false,
- spam=false
- },
- {
- nom="neige rouge",
- defaut=false,
- bouton=colors.magenta,
- red=ahb.addPeripheral("hb_interupteur_16"),
- dure=40,
- delay=80,
- curs=0,
- actif=false,
- spam=true,
- spamVar=2
- },
- {
- nom="trappe rouge",
- defaut=false,
- bouton=colors.orange,
- red=ahb.addPeripheral("hb_interupteur_24"),
- dure=10,
- delay=1,
- curs=0,
- actif=false,
- spam=false
- }
- }
- moniteur=ahb.addPeripheral("monitor_2")
- timerVictoire=false
- depart1=ahb.addPeripheral("hb_interupteur_21")
- depart1.pp.set(15)
- go=0
- note=ahb.addPeripheral("noteBlock_0")
- function routine()
- for i, data in pairs(liste) do
- if data.defaut then
- data.red.pp.set(15)
- else
- data.red.pp.set(0)
- end
- end
- while true do
- for i, data in pairs(liste) do
- if data.actif then
- if data.curs==0 then
- if data.defaut then
- data.red.pp.set(0)
- else
- data.red.pp.set(15)
- end
- print(data.nom..' debut activation')
- elseif data.curs<data.dure then
- if data.spam then
- if math.floor(data.curs/data.spamVar)%2==1 then
- if data.defaut then
- data.red.pp.set(15)
- else
- data.red.pp.set(0)
- end
- else
- if data.defaut then
- data.red.pp.set(0)
- else
- data.red.pp.set(15)
- end
- end
- print(data.nom..' spam')
- end
- elseif data.curs==data.dure then
- if data.defaut then
- data.red.pp.set(15)
- else
- data.red.pp.set(0)
- end
- print(data.nom..' fin activation')
- elseif data.curs==data.dure+data.delay then
- liste[i].curs=-1
- liste[i].actif=false
- print(data.nom..' fin du delay')
- end
- liste[i].curs=liste[i].curs+1
- end
- end
- if not(go==0) then
- go=go-1
- if go%20==0 and go~=0 then
- note.pp.playNote(0,0)
- end
- if go==0 then
- note.pp.playNote(0,15)
- depart1.pp.set(0)
- timerVictoire=true
- end
- end
- os.sleep(0.05)
- end
- end
- function ecoute()
- while true do
- local event = os.pullEvent("redstone")
- print("ecoute")
- if redstone.getInput("left") or redstone.getInput("right") then
- moniteur.pp.setBackgroundColor(colors.black)
- moniteur.pp.clear()
- go=20*4
- end
- if timerVictoire==true then
- if redstone.testBundledInput("bottom",colors.white) then
- -- ROUGE GAGNE
- moniteur.pp.setBackgroundColor(colors.red)
- moniteur.pp.clear()
- moniteur.pp.setCursorPos(1,1)
- moniteur.pp.setTextScale(5)
- moniteur.pp.write("Rouge gagne")
- timerVictoire=false
- depart1.pp.set(15)
- end
- if redstone.testBundledInput("bottom",colors.black) then
- moniteur.pp.setBackgroundColor(colors.blue)
- moniteur.pp.clear()
- moniteur.pp.setCursorPos(1,1)
- moniteur.pp.setTextScale(5)
- moniteur.pp.write("Bleu gagne")
- timerVictoire=false
- depart1.pp.set(15)
- -- BLEU GAGNE
- end
- if redstone.testBundledInput("bottom",colors.white) and redstone.testBundledInput("bottom",colors.black) then
- moniteur.pp.setBackgroundColor(colors.black)
- moniteur.pp.clear()
- moniteur.pp.setCursorPos(1,1)
- moniteur.pp.setTextScale(5)
- moniteur.pp.write("Egalite")
- timerVictoire=false
- depart1.pp.set(15)
- end
- end
- for i, data in pairs(liste) do
- if redstone.testBundledInput("bottom",data.bouton) then
- print(data.nom..' bouton '..tostring(data.actif)..' '..data.curs)
- liste[i].actif=true
- end
- end
- end
- end
- parallel.waitForAll(routine,ecoute)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement