Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("top")
- local names={}
- local f=fs.open("/card-index","r")
- if f then
- local s=f.readLine()
- while s do
- for name,pass in string.gmatch(s,"(.-)|(.-)|") do
- print(name,"|",pass)
- names[name]=pass
- end
- s=f.readLine()
- end
- f.close()
- end
- while true do
- local id,data=rednet.receive()
- if data:sub(1,11)=="CARD|CHECK|" then
- local ok=false
- print("Checking "..data:sub(11).." from id "..id)
- for name,pass in string.gmatch(data:sub(11),"|(.-)|(.-)|") do
- for k,v in pairs(names) do
- if k==name and v==pass then
- ok=true
- break
- end
- end
- end
- print(ok)
- if ok then rednet.send(id,"CARD|OK") else
- rednet.send(id,"CARD|BAD")
- end
- elseif data:sub(1,9)=="CARD|ADD|" then
- print("adding card " .. data:sub(9).. " from id "..id)
- local f=fs.open("/card-index","a")
- f.write(data:sub(10))
- elseif id~=176 then print(data) end
- end
Advertisement
Add Comment
Please, Sign In to add comment