View difference between Paste ID: X18LDU2W and iRgfjUZL
SHOW: | | - or go back to the newest paste.
1-
rednet.open("top")
1+
rednet.open("bottom")
2
3
local names={}
4
local f=fs.open("/card-index","r")
5
if f then
6
7
local s=f.readLine()
8
while s do
9-
for name,pass in string.gmatch(s,"(.-)|(.-)|") do
9+
for name,pass,rooms in string.gmatch(s,"(.-)|(.-)|(.-)|") do
10
print(name,"|",pass)
11-
names[name]=pass
11+
names[name]={pass,rooms}
12
end
13
s=f.readLine()
14
end
15
f.close()
16
end
17
18
while true do
19
  local id,data=rednet.receive() 
20
  
21
  if data:sub(1,11)=="CARD|CHECK|" then
22
    local ok=false
23
    print("Checking "..data:sub(11).." from id "..id)
24
    for name,pass in string.gmatch(data:sub(11),"|(.-)|(.-)|") do
25
      for k,v in pairs(names) do
26-
        if k==name and v==pass then
26+
        if k==name and v[1]==pass then
27-
          ok=true
27+
          ok=v[2]
28
          break
29
        end
30
      end
31
    end
32-
    print(ok)
32+
    if ok then rednet.send(id,"CARD|OK|"..ok) else
33-
    if ok then rednet.send(id,"CARD|OK") else
33+
34
    end
35
  elseif data:sub(1,8)=="CARD|ADD|" and id== then
36-
  elseif data:sub(1,8)=="CARD|ADD|" then
36+
37
    local f=fs.open("/card-index","a")
38
    f.write(data:sub(9))
39
   end
40-
  elseif id~=176 then print(data) end
40+