SHOW:
|
|
- or go back to the newest paste.
| 1 | -- MERDOR (FIH) & ARC (CFG) | |
| 2 | -- Variabili di MERDOR | |
| 3 | pc1 = "" | |
| 4 | - | pc2 = "" |
| 4 | + | |
| 5 | - | pc3 = "" |
| 5 | + | |
| 6 | - | pc4 = "" |
| 6 | + | -- MERDOR di [[1]] |
| 7 | ||
| 8 | - | -- MERDOR di djcrash01 |
| 8 | + | |
| 9 | ||
| 10 | --Inizializzo le funzioni | |
| 11 | function getAPI(API, computer) | |
| 12 | risposta = http.get("https://arc.rgbcraft.com/api/get/switch?token="..token.."&computer="..computer)
| |
| 13 | if risposta ~= nil and ris ~= "" then | |
| 14 | - | risposta = http.get("https://arc.rgbcraft.com/API/get/switch?token="..token.."&computer="..computer)
|
| 14 | + | |
| 15 | b = textutils.unserialize(a) | |
| 16 | end | |
| 17 | return b | |
| 18 | end | |
| 19 | ||
| 20 | function header(text) | |
| 21 | term.setCursorPos(18, 1) | |
| 22 | print(text) | |
| 23 | end | |
| 24 | ||
| 25 | function interfacciaNonConfigurata() | |
| 26 | term.clear() | |
| 27 | header("MERDOR - Installazione")
| |
| 28 | print("\n\nInserisci il token di Arc")
| |
| 29 | local tokenArc = read() | |
| 30 | print("\nPerfetto! Ora inserisci il numero del Computer di Arc!")
| |
| 31 | print("RICORDA che Computer1 su arc e' 0 e Computer2 e' 1")
| |
| 32 | local pcArc = read() | |
| 33 | ||
| 34 | -- Sistemo tutto nel file di configurazione | |
| 35 | file = fs.open(".settings", "w")
| |
| 36 | file.writeLine("token = '"..tokenArc.."'")
| |
| 37 | file.writeLine("computer = "..pcArc)
| |
| 38 | - | file.writeLine("computer = '"..pcArc.."'")
|
| 38 | + | |
| 39 | -- Restarto il programma | |
| 40 | shell.run("startup")
| |
| 41 | end | |
| 42 | ||
| 43 | function interfacciaUtente() | |
| 44 | term.clear() | |
| 45 | header("MERDOR & ARC")
| |
| 46 | print("\n\nMERDOR e Arc stanno lavorando correttamente su questo computer")
| |
| 47 | print("\nPer fermare il programma fai CTRL + T per 5 secondi")
| |
| 48 | end | |
| 49 | ||
| 50 | - | function apiElaborateToken(pc1, pc2, pc3, pc4, api, computer) |
| 50 | + | function apiElaborateToken(pc1, api, computer, repe) |
| 51 | local api = getAPI(api, computer) | |
| 52 | me1 = api.left | |
| 53 | - | me2 = api.back |
| 53 | + | |
| 54 | - | me3 = api.front |
| 54 | + | if me1 == 1 and repe ~= 1 then |
| 55 | - | me4 = api.right |
| 55 | + | |
| 56 | rednet.send(pc1, "ON") | |
| 57 | - | if me1 == 1 then |
| 57 | + | |
| 58 | end | |
| 59 | elseif me1 == 0 then | |
| 60 | rednet.send(pc1, "OFF") | |
| 61 | print("MERDOR 1 [ ON -> OFF ]")
| |
| 62 | end | |
| 63 | end | |
| 64 | ||
| 65 | - | if me2 == 1 then |
| 65 | + | |
| 66 | -- Inizio il programma | |
| 67 | - | rednet.send(pc2, "ON") |
| 67 | + | term.clear() |
| 68 | - | print("MERDOR 2 [ OFF -> ON ]")
|
| 68 | + | |
| 69 | - | elseif me2 == 0 then |
| 69 | + | |
| 70 | - | rednet.send(pc2, "OFF") |
| 70 | + | |
| 71 | - | print("MERDOR 2 [ ON -> OFF ]")
|
| 71 | + | shell.run(".settings")
|
| 72 | interfacciaUtente() | |
| 73 | - | if me3 == 1 then |
| 73 | + | |
| 74 | local repe = apiElaborateToken(pc1, token, computer, repe) | |
| 75 | - | rednet.send(pc3, "ON") |
| 75 | + | |
| 76 | - | print("MERDOR 3 [ OFF -> ON ]")
|
| 76 | + | |
| 77 | - | elseif me2 == 0 then |
| 77 | + | |
| 78 | - | rednet.send(pc3, "OFF") |
| 78 | + | |
| 79 | - | print("MERDOR 3 [ ON -> OFF ]
|
| 79 | + | |
| 80 | ||
| 81 | - | if me4 == 1 then |
| 81 | + | |
| 82 | ||
| 83 | - | rednet.send(pc4, "ON") |
| 83 | + | |
| 84 | - | print("MERDOR 4 [ OFF -> ON ]")
|
| 84 | + |