2016-07-04 38 views
0

我不断收到第61行的预期错误,我无法找到问题的任何想法? 我试图努力出来,并重新安排其即时通讯使用电脑工艺periherals MAG读卡器,并试图MAG卡门我一直得到一个预期的错误,当我有字符串

os.loadAPI("SHA") 
 
os.pullEvent = os.pullEventRaw 
 

 
redstone.setBundledOutput("left",colors.white) 
 
math.randomseed(os.time()) 
 

 
term.clear() 
 
term.setCursorPos(1,1) 
 
print("DKM.inc Doors") 
 
print("thank you") 
 

 
modem = peripheral.wrap("top") 
 

 
if moden == nil then 
 
    error("Modem not on top") 
 
end 
 

 
if moden.isPresentRemote("mag card reader_0") then 
 
    reader = peripheral.wrap("mag card reader_0") 
 
    print("Card reader connected") 
 
else 
 
    error("Mag-card reader not found") 
 
end 
 

 
if modem.isPresentRemote("monitor_0") then 
 
    monitor = peripheral.wrap("monitor_0") 
 
    print("monitor connected") 
 
else 
 
    error("monitor not found") 
 
end 
 

 
hashedPw = "0706490" 
 
cardsFilePath = "cards" 
 
cards = {""} 
 
chars = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} 
 
newpass = "" 
 
cardNum = 0 
 

 
if fs.exists(cardsFilePath) then 
 
    cardsFile = fs.open(cardsFilePath, "r") 
 
    cards = textutils.unserialize(cardsFile.readAll()) 
 
    cardsFile.close() 
 
end 
 

 
while true do 
 
    admin = false 
 
    
 
    monitor.clear() 
 
    monitor.setCursorPos(1,1) 
 
    monitor.write("Please insert card") 
 
    reader.setInsertCardLight(true) 
 
    
 
    
 
    event, p1,p2,p3 = os.pullEvent() 
 
    
 
    if event == " mag_swipe" then 
 
    if SHA.SHA1_2(p1) == hashePw then 
 
     admin = true 
 
    end 
 
    for x = 1, #cards do 
 
     if SHA,SHA1_2(p1) == cards[x] then --line 61 is right here 
 
     reader.setInsertCardLight(false) 
 
     redstone.setBundledOutput("left", 0) 
 
     os.sleep(3) 
 
     redstone.setBundledOutput("left", colors.white) 
 
     reader.setInsertCardLight(true) 
 
     break 
 
     end 
 
    end 
 
    end 
 
    if admin == true then 
 
    reader.setInsertCardLight(false) 
 
    monitor.clear() 
 
    monitor.setCursorPos(1,1) 
 
    monitor.write("Admin granted insert blank card") 
 
    for z = 1,15 do 
 
     case math.random(1,2) 
 
     a = math.random(1,#chars) 
 
     if case == 1 then 
 
     x=string.upper(chars[a]) 
 
     elseif case == 2 then 
 
     x=string.lower(chars[a]) 
 
     end 
 
     newpass = newpass..x 
 
    end 
 
    reader.setInsertCardLight(true) 
 
    cardNum = #cards 
 
    print(reader.beginWrite(newpass, cardNum.."")) 
 
    table.insert(cards, SHA,SHA1_2(newpass)) 
 
    
 
    while reader.isWaiting() do 
 
    end 
 
    
 
    reader.setInsertCardLight(false) 
 
    monitor.clear() 
 
    monitor.setCursorPos(1,1) 
 
    monitor.write("new card created") 
 
    newpass = "" 
 
    end 
 

 
    os.sleep(1) 
 
    
 
    cardsFile = fs.open(cardsFilePath, "w") 
 
    cardsFile.write(textutils.serialize(cards)) 
 
    cardsFile.close() 
 

 
end

+0

你能发表评论@第61行,以便我们可以看到错误发生在哪里? thx – Thomas

+0

我改变了它在行尾有注释的地方 –

+0

我认为你必须用SHA.SHA1_2(komata)替换SHA,SHA1_2 – Thomas

回答

0

你错过拼写为“调制解调器”与MODEN上2行。

if moden == nil then 

也..

if moden.isPresentRemote("mag card reader_0") then 

至于错误。

if SHA,SHA1_2(p1) == cards[x] then --line 61 is right here 

我相信..应该是这样..

if SHA.SHA1_2(p1) == cards[x] then --line 61 is right here 

调换,.应该做的伎俩。

相关问题