SHOW:
|
|
- or go back to the newest paste.
| 1 | ---------------- CONFIG ----------------------------------------------- | |
| 2 | m = peripheral.wrap("top") -- side wieless modem
| |
| 3 | mW = peripheral.wrap("right") --m side wired modem
| |
| 4 | os.loadAPI("AF") -- crypting/decrypting API by Zer0Galaxy
| |
| 5 | key = AF.getkey("HsGT4*523GuH") -- key
| |
| 6 | ------------------------------------------------------------------------- | |
| 7 | m.open(50) | |
| 8 | mW.open(51) | |
| 9 | ||
| 10 | --crypt and send | |
| 11 | function sendC(ms) | |
| 12 | pms = AF.crypt(ms,key) | |
| 13 | m.transmit(50,50,pms) | |
| 14 | end | |
| 15 | ||
| 16 | --writing log | |
| 17 | function WTfile(ms) | |
| 18 | f = fs.open("log",fs.exists("log") and "a" or "w")
| |
| 19 | f.writeLine(ms) | |
| 20 | f.close() | |
| 21 | end | |
| 22 | ||
| 23 | --recive and decrypt | |
| 24 | function RDEC() | |
| 25 | e,p1,p2,p3,p4,p5 = os.pullEvent("modem_message")
| |
| 26 | Oms = AF.decrypt(p4,key) | |
| 27 | return Oms | |
| 28 | end | |
| 29 | ||
| 30 | --gmatch universal | |
| 31 | function Gsel(ms,form,times) | |
| 32 | mu = {}
| |
| 33 | if times == 2 then | |
| 34 | for k,v in string.gmatch(ms, form) do | |
| 35 | return k,v | |
| 36 | end | |
| 37 | elseif times == 3 then | |
| 38 | for k,v,j in string.gmatch(ms,form) do | |
| 39 | return k,v,j | |
| 40 | end | |
| 41 | end | |
| 42 | end | |
| 43 | ||
| 44 | while true do | |
| 45 | ||
| 46 | A = {}
| |
| 47 | E,SM,NC,SRC,TM,DS = os.pullEvent("modem_message")
| |
| 48 | RM = AF.decrypt(TM,key) | |
| 49 | for k,v in string.gmatch(RM, "(.+)=(.+)") do | |
| 50 | A[1] = k | |
| 51 | A[2] = v | |
| 52 | end | |
| 53 | --log | |
| 54 | print(A[1]," ",A[2]) | |
| 55 | if A[1] or A[2] == nil then | |
| 56 | if A[2] and A[1] == nil then | |
| 57 | WTfile("nil command and nil args!")
| |
| 58 | elseif A[2] == nil then | |
| 59 | WTfile("nil args, command is "..A[1])
| |
| 60 | elseif A[1] then | |
| 61 | WTfile("nil command,args is "..A[2])
| |
| 62 | end | |
| 63 | else | |
| 64 | WTfile(A[1].." "..A[2]) | |
| 65 | end | |
| 66 | --main | |
| 67 | -- getEU function . need addifical modules | |
| 68 | if A[1] == "getEU" then | |
| 69 | mW.transmit(51,51,A[1]) | |
| 70 | e,p1,p2,p3,p4 = os.pullEvent("modem_message")
| |
| 71 | print(p4) | |
| 72 | sendC(tostring(p4)) | |
| 73 | -- getDS function | |
| 74 | elseif A[1] == "getDS" then | |
| 75 | sendC(tostring(DS)) | |
| 76 | elseif A[1] == "user" then | |
| 77 | -- getRCS function . need addifical modules | |
| 78 | elseif A[1] == "getRCS" then | |
| 79 | mW.transmit(51,51,"getRCST") | |
| 80 | e,p1,p2,p3,p4,p5 = os.pullEvent("modem_message")
| |
| 81 | print(p4) | |
| 82 | H,AC,EU = Gsel(p4,"%w+=(%w+);(%w+);(%w+)",3) | |
| 83 | print(" Reactor:")
| |
| 84 | if not H or AC or EU == nil then | |
| 85 | print("Heat:"..H)
| |
| 86 | print("Status"..AC and "Inactive" or "Active")
| |
| 87 | print("Output:"..EU)
| |
| 88 | end | |
| 89 | m.transmit(50,50,AF.crypt("REC="..H..";"..AC..";"..EU,key))
| |
| 90 | ||
| 91 | --beta function ( now i cant say will be him if fithure | |
| 92 | elseif A[1] == "actR" then | |
| 93 | mW.transmit(51,51,"actR") | |
| 94 | ||
| 95 | elseif A[1] == "disR" then | |
| 96 | mW.transmit(51,51,"disR") | |
| 97 | -- basic function "add" , "rm" , "rOpen" . add player to door system , remove player from door system , remote door open . need addifical modules | |
| 98 | elseif A[1] == "add" or "rm" or "rOpen" then | |
| 99 | mW.transmit(51,51,A[1].."="..A[2]) | |
| 100 | end | |
| 101 | end |