Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("bottom")
- local names={}
- local f=fs.open("/card-index","r")
- if f then
- local s=f.readLine()
- while s do
- for name,pass,rooms in string.gmatch(s,"(.-)|(.-)|(.-)|") do
- print(name,"|",pass)
- names[name]={pass,rooms}
- 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[1]==pass then
- ok=v[2]
- break
- end
- end
- end
- if ok then rednet.send(id,"CARD|OK|"..ok) else
- rednet.send(id,"CARD|BAD")
- end
- elseif data:sub(1,8)=="CARD|ADD|" and id== then
- print("adding card " .. data:sub(8).. " from id "..id)
- local f=fs.open("/card-index","a")
- f.write(data:sub(9))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment