Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- MERDOR (FIH) & ARC (CFG)
- -- Variabili di MERDOR
- pc1 = ""
- rednetPos = "top"
- -- MERDOR di [[1]]
- rednet.open("top")
- --Inizializzo le funzioni
- function getAPI(API, computer)
- risposta = http.get("https://arc.rgbcraft.com/api/get/switch?token="..token.."&computer="..computer)
- if risposta ~= nil and ris ~= "" then
- a = http.get("https://arc.rgbcraft.com/api/get/switch?token="..token.."&computer="..computer).readAll()
- b = textutils.unserialize(a)
- end
- return b
- end
- function header(text)
- term.setCursorPos(18, 1)
- print(text)
- end
- function interfacciaNonConfigurata()
- term.clear()
- header("MERDOR - Installazione")
- print("\n\nInserisci il token di Arc")
- local tokenArc = read()
- print("\nPerfetto! Ora inserisci il numero del Computer di Arc!")
- print("RICORDA che Computer1 su arc e' 0 e Computer2 e' 1")
- local pcArc = read()
- -- Sistemo tutto nel file di configurazione
- file = fs.open(".settings", "w")
- file.writeLine("token = '"..tokenArc.."'")
- file.writeLine("computer = "..pcArc)
- file.close()
- -- Restarto il programma
- shell.run("startup")
- end
- function interfacciaUtente()
- term.clear()
- header("MERDOR & ARC")
- print("\n\nMERDOR e Arc stanno lavorando correttamente su questo computer")
- print("\nPer fermare il programma fai CTRL + T per 5 secondi")
- end
- function apiElaborateToken(pc1, api, computer, repe)
- local api = getAPI(api, computer)
- me1 = api.left
- if me1 == 1 and repe ~= 1 then
- -- Merdor1
- rednet.send(pc1, "ON")
- print("MERDOR 1 [ OFF -> ON ]")
- end
- elseif me1 == 0 then
- rednet.send(pc1, "OFF")
- print("MERDOR 1 [ ON -> OFF ]")
- end
- end
- -- Inizio il programma
- term.clear()
- if fs.exists(".settings") == false then
- interfacciaNonConfigurata()
- else
- shell.run(".settings")
- interfacciaUtente()
- while true do
- local repe = apiElaborateToken(pc1, token, computer, repe)
- sleep(0.5)
- end
- end
Add Comment
Please, Sign In to add comment