Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------- CONFIG -----------------------------------------------
- m = peripheral.wrap("top") -- side wieless modem
- mW = peripheral.wrap("right") --m side wired modem
- os.loadAPI("AF") -- crypting/decrypting API by Zer0Galaxy
- key = AF.getkey("HsGT4*523GuH") -- key
- -------------------------------------------------------------------------
- m.open(50)
- mW.open(51)
- --crypt and send
- function sendC(ms)
- pms = AF.crypt(ms,key)
- m.transmit(50,50,pms)
- end
- --writing log
- function WTfile(ms)
- f = fs.open("log",fs.exists("log") and "a" or "w")
- f.writeLine(ms)
- f.close()
- end
- --recive and decrypt
- function RDEC()
- e,p1,p2,p3,p4,p5 = os.pullEvent("modem_message")
- Oms = AF.decrypt(p4,key)
- return Oms
- end
- --gmatch universal
- function Gsel(ms,form,times)
- mu = {}
- if times == 2 then
- for k,v in string.gmatch(ms, form) do
- return k,v
- end
- elseif times == 3 then
- for k,v,j in string.gmatch(ms,form) do
- return k,v,j
- end
- end
- end
- while true do
- A = {}
- E,SM,NC,SRC,TM,DS = os.pullEvent("modem_message")
- RM = AF.decrypt(TM,key)
- for k,v in string.gmatch(RM, "(.+)=(.+)") do
- A[1] = k
- A[2] = v
- end
- --log
- print(A[1]," ",A[2])
- if A[1] or A[2] == nil then
- if A[2] and A[1] == nil then
- WTfile("nil command and nil args!")
- elseif A[2] == nil then
- WTfile("nil args, command is "..A[1])
- elseif A[1] then
- WTfile("nil command,args is "..A[2])
- end
- else
- WTfile(A[1].." "..A[2])
- end
- --main
- -- getEU function . need addifical modules
- if A[1] == "getEU" then
- mW.transmit(51,51,A[1])
- e,p1,p2,p3,p4 = os.pullEvent("modem_message")
- print(p4)
- sendC(tostring(p4))
- -- getDS function
- elseif A[1] == "getDS" then
- sendC(tostring(DS))
- elseif A[1] == "user" then
- -- getRCS function . need addifical modules
- elseif A[1] == "getRCS" then
- mW.transmit(51,51,"getRCST")
- e,p1,p2,p3,p4,p5 = os.pullEvent("modem_message")
- print(p4)
- H,AC,EU = Gsel(p4,"%w+=(%w+);(%w+);(%w+)",3)
- print(" Reactor:")
- if not H or AC or EU == nil then
- print("Heat:"..H)
- print("Status"..AC and "Inactive" or "Active")
- print("Output:"..EU)
- end
- m.transmit(50,50,AF.crypt("REC="..H..";"..AC..";"..EU,key))
- --beta function ( now i cant say will be him if fithure
- elseif A[1] == "actR" then
- mW.transmit(51,51,"actR")
- elseif A[1] == "disR" then
- mW.transmit(51,51,"disR")
- -- basic function "add" , "rm" , "rOpen" . add player to door system , remove player from door system , remote door open . need addifical modules
- elseif A[1] == "add" or "rm" or "rOpen" then
- mW.transmit(51,51,A[1].."="..A[2])
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement