我一直在第61行得到当时预期的错误,我无法找到问题的任何想法? 我尝试使用计算机工艺周边磁卡读卡器重新安排它并尝试重新安装卡门
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 :(得分:1)
你错过拼写"调制解调器" with moden on 2 lines。
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
为,
交换.
应该可以解决问题。