Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ahb")
- score=0
- cibles={
- {
- cote="top",
- coef=1,
- qte=0,
- reds=ahb.addPeripheral("hb_interupteur_28")
- },
- {
- cote="right",
- coef=1.5,
- qte=0,
- reds=ahb.addPeripheral("hb_interupteur_29")
- },
- {
- cote="left",
- coef=2,
- qte=0,
- reds=ahb.addPeripheral("hb_interupteur_30")
- },
- {
- cote="back",
- coef=2.5,
- qte=0,
- reds=ahb.addPeripheral("hb_interupteur_31")
- }
- }
- cibles[1].reds.pp.set(0)
- cibles[2].reds.pp.set(0)
- cibles[3].reds.pp.set(0)
- cibles[4].reds.pp.set(0)
- moniteur=ahb.addPeripheral("monitor_3")
- moniteur.pp.setBackgroundColor(colors.black)
- moniteur.pp.setTextScale(5)
- son=ahb.addPeripheral("noteBlock_1")
- distri=ahb.addPeripheral("hb_interupteur_36")
- distri.pp.set(0)
- function cibleSuivante()
- cible=cible+1
- cibles[1].reds.pp.set(0)
- cibles[2].reds.pp.set(0)
- cibles[3].reds.pp.set(0)
- cibles[4].reds.pp.set(0)
- if cible==1 then
- score=0
- moniteur.pp.clear()
- moniteur.pp.setCursorPos(1,1)
- moniteur.pp.write(score)
- end
- if cible<5 then
- distri.pp.set(15)
- os.sleep(0.2)
- distri.pp.set(0)
- os.sleep(0.2)
- distri.pp.set(15)
- os.sleep(0.2)
- distri.pp.set(0)
- print("Cible "..tostring(cible).." "..cibles[cible].cote)
- cibles[cible]['qte']=0
- cibles[cible].reds.pp.set(15)
- else
- cible=0
- end
- end
- cible=0
- while true do
- local event = os.pullEvent("redstone")
- print("Redstone")
- if redstone.getInput("front") then
- cibleSuivante()
- else
- if not(cible==0) then
- cibles[cible]['force']=redstone.getAnalogInput(cibles[cible]["cote"])
- if not(cibles[cible]['force']==0) then
- print(cibles[cible]['force'])
- if cibles[cible]['qte']<2 then
- son.pp.playNote(0,cibles[cible]['force'])
- score=score+(cibles[cible]['force']*cibles[cible]['coef'])
- moniteur.pp.clear()
- moniteur.pp.setCursorPos(1,1)
- moniteur.pp.write(score)
- cibles[cible]['qte']=cibles[cible]['qte']+1
- if cibles[cible]['qte']==2 then
- cibleSuivante()
- end
- else
- cibleSuivante()
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement