Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uscite = 0;
- function clear()
- term.clear()
- term.setCursorPos(1, 1)
- term.setBackgroundColour(colours.black)
- term.setTextColor(colors.white)
- end
- function colore()
- term.setTextColour(sfumatura)
- end
- function fineColore()
- term.setTextColour(colours.white)
- end
- function sfondo(sfumaturaSfondo)
- term.setBackgroundColour(sfumaturaSfondo)
- end
- function fineSfondo()
- term.setBackgroundColour(colours.black)
- end
- function leggiStatoUscite()
- if fs.exists("uscite") == true then
- handle = fs.open("uscite", "r")
- uscite = tonumber(handle.readAll())
- handle.close()
- else
- handle = fs.open("uscite", "w")
- handle.write(tostring(uscite))
- handle.close()
- end
- end
- function salvaStatoUscite()
- handle = fs.open("uscite", "w")
- handle.write(tostring(uscite))
- handle.close()
- end
- function attivaUscite()
- rs.setBundledOutput("back", uscite)
- end
- function controllaSeAcceso(binario)
- if colors.test(rs.getBundledInput("back"), binario) == true then
- return true
- else
- return false
- end
- end
- function disegnaOnOff(coloreCavoOnOff)
- if colors.test(uscite, coloreCavoOnOff) == true then
- sfondo(colors.lime)
- term.write("ON")
- fineSfondo()
- else
- sfondo(colors.red)
- term.write("OFF")
- fineSfondo()
- end
- end
- function disegnaStrutturaQuadro()
- clear()
- print("Electrosila\n\n")
- print("Linea 66 kV")
- print("Linea 6 kV")
- print("Applied ener.")
- print("Caricabatteria")
- term.setCursorPos(13,3)
- disegnaOnOff(1)
- term.setCursorPos(13,4)
- disegnaOnOff(2)
- term.setCursorPos(13,5)
- disegnaOnOff(4)
- term.setCursorPos(13,6)
- disegnaOnOff(8)
- end
- leggiStatoUscite()
- attivaUscite()
- while true do
- attivaUscite()
- disegnaStrutturaQuadro()
- evento, pulsante, x, y = os.pullEvent( "monitor_touch" )
- if y == 3 then
- if controllaSeAcceso(1) == true then
- uscite = uscite - 1
- else
- uscite = uscite + 1
- end
- elseif y == 4 then
- if controllaSeAcceso(2) == true then
- uscite = uscite - 2
- else
- uscite = uscite + 2
- end
- elseif y == 5 then
- if controllaSeAcceso(4) == true then
- uscite = uscite - 4
- else
- uscite = uscite + 4
- end
- elseif y == 6 then
- if controllaSeAcceso(8) == true then
- uscite = uscite - 8
- else
- uscite = uscite + 8
- end
- elseif y == 7 then
- if controllaSeAcceso(16) == true then
- uscite = uscite - 16
- else
- uscite = uscite + 16
- end
- elseif y == 8 then
- if controllaSeAcceso(32) == true then
- uscite = uscite - 32
- else
- uscite = uscite + 32
- end
- else
- uscite = uscite
- end
- salvaStatoUscite()
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement