Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- print("Programma per comandi singoli quarry-repka")
- print("")
- redstone_quarry="left"
- redstone_finish="back"
- r_avanti=colors.red
- r_indietro=colors.blue
- r_sx=colors.pink
- r_dx=colors.lime
- r_finish=colors.red
- t_pausa_mining=16
- m=peripheral.wrap("top")
- function draw_line_term(monitor,x, y, length, color)
- monitor.setBackgroundColor(color)
- monitor.setCursorPos(x,y)
- monitor.write(string.rep(" ", length))
- end
- function progress_bar_term(monitor,x, y,length, curr, maxVal, bar_color, bg_color)
- draw_line_term(monitor,x, y, length, bg_color) --backgoround bar
- local howmuch=maxVal/length
- local barSize = math.floor((curr/howmuch))
- draw_line_term(monitor,x, y, barSize, bar_color) --progress so far
- monitor.setCursorPos(x+math.floor(length/2)-1 ,y-1)
- local perc=math.floor(curr*100/maxVal)
- monitor.setBackgroundColor(colors.black)
- monitor.write(perc.."%")
- monitor.setCursorPos(x+math.floor(length/2)-4,y+2)
- monitor.write(curr.." / "..maxVal)
- end
- function impulso(lato,colore)
- redstone.setBundledOutput(lato,colore)
- sleep(1)
- redstone.setBundledOutput(lato,0)
- end
- function muovi(colore,volte,skip)
- for i=1,volte,1 do
- print("Muovendo "..i.."/"..volte)
- impulso(redstone_quarry,colore)
- m.clear()
- progress_bar_term(m,2,2,25,i,volte,colors.lime,colors.lightGray)
- if skip=="n" then
- sleep(4)
- else
- print("Sto minando..")
- m.setCursorPos(15,5)
- m.write("Sto minando...")
- sleep(t_pausa_mining)
- end
- end
- end
- redstone.setBundledOutput(redstone_quarry,0)
- redstone.setBundledOutput(redstone_finish,0)
- print("Direzione?")
- print("1 - Avanti")
- print("2 - Indietro")
- print("3 - Sinistra")
- print("4 - Destra")
- local dir=read()
- print("")
- print("Quanti movimenti? es:10")
- local vol=read()
- print("")
- print("Vuoi fermarti a minare? y/n")
- local skip=read()
- if dir=="1" then
- print("Avanti di "..vol.." !")
- muovi(r_avanti,vol,skip)
- elseif dir=="2" then
- print("Indietro di "..vol.." !")
- muovi(r_indietro,vol,skip)
- elseif dir=="3" then
- print("Sinistra di "..vol.." !")
- muovi(r_sx,vol,skip)
- elseif dir=="4" then
- print("Destra di "..vol.." !")
- muovi(r_dx,vol,skip)
- else
- print("ERRORE COMANDO SCONOSCIUTO")
- end
- print("Finito :)")
- redstone.setBundledOutput(redstone_finish,r_finish)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement