2016-07-04 5 views
0

61 번째 줄에 예상되는 오류가 계속 발생하고 어떤 문제가 발견되지 않습니까? 나는 그것을 밖으로 작동하고 컴퓨터 공예 periherals 잡지 카드 판독기를 사용하여 메신저 정리하고 당신은 2 개 라인에 MODEN으로 "모뎀"철자가 그리워 카드 도어문자열을 가지고있을 때 예상 오류가 계속 발생합니다.

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

오류가 발생한 위치를 알 수 있도록 @ line 61 주석을 달 수 있습니까? thx – Thomas

+0

줄 끝 부분에 주석이있는 곳에서 바 꾸었습니다 –

+0

SHA, SHA1_2를 SHA.SHA1_2 (komata)로 바꿔야한다고 생각합니다 – Thomas

답변

0

을 매기려고 노력했다.

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 

트릭을 할해야 .,를 교환.

관련 문제