Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Inizializza Rednet
- rednet.open("bottom")
- --ID dei computer receiver
- local targetIDs = {21, 23, 25}
- -- invio a tutti i target ID
- local function sendToAll(message)
- for _, id in ipairs(targetIDs) do
- rednet.send(id, message)
- end
- end
- -- controllo il segnale redstone e invio messaggi
- function checkRedstoneSignals()
- local leftSignal = redstone.getInput("left")
- local rightSignal = redstone.getInput("right")
- while true do
- local newleftSignal = redstone.getInput("left")
- local newrightSignal = redstone.getInput("right")
- -- Sopra è cambiato da acceso a spento
- if leftSignal and not newleftSignal then
- redstone.setOutput("top", false)
- sendToAll("lasciando piano 1")
- print("lasciando piano 1")
- end
- -- sopra è cambiato da spento ad acceso
- if not leftSignal and newleftSignal then
- redstone.setOutput("top", true)
- sendToAll("stop")
- print("stop")
- end
- -- sinistra è cambiato da acceso a spento
- if rightSignal and not newrightSignal then
- sendToAll("lasciando piano 2")
- print("lasciando piano 2")
- end
- -- sinistra è cambiato da spento ad acceso
- if not rightSignal and newrightSignal then
- sendToAll("stop")
- print("stop")
- end
- -- Aggiorna gli stati dei segnali
- leftSignal = newleftSignal
- rightSignal = newrightSignal
- -- dormi dormi fiorellino
- sleep(0.3)
- end
- end
- -- inizio
- checkRedstoneSignals()
Advertisement
Add Comment
Please, Sign In to add comment