Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- ================================ CONFIGS ====================================
- CRIADO POR: HAYDEN ALMEIDA
- Canal no youTube: https://www.youtube.com/channel/UCUZCQ1q0ZOHpqABIvpxB32g
- local data = "06/05/2016 as 2331" data de atualizaçao
- Caso encontre um erro e quiser entrar em contato: haydenalmeida@hotmail.com
- Ou Skype: haydenalmeida
- --]]
- local ver = "1.0" -- versao atual do programa
- local Tog_Debug = false -- if Tog_Debug == true then print("Debug 1") end -- DEBUG
- PC_ID = os.getComputerID()
- --======================== FIM DAS CONFIGS ===================================
- local file = fs.open("//configs/start", "r")
- local ler1 = file.readLine()
- local ler2 = file.readLine()
- file.close()
- diskDriveSide = tostring(ler1)
- NetSide = tostring(ler2)
- local function Tela()
- term.setBackgroundColor(colors.blue)
- term.clear()
- term.setCursorPos(1, 1)
- term.setTextColor(colors.black)
- end
- Tela()
- print("Insira o Cartao do Gerente para continuar e aperte ENTER.")
- local ENTER = read("#")
- if disk.isPresent(diskDriveSide) == true then
- if fs.exists("disk/usuario") then
- local ab = fs.open("disk/usuario", "r")
- Gerente = ab.readLine()
- ab.close()
- if Tog_Debug == true then print("Debug 1") end -- DEBUG
- local Disco_ID = tostring(disk.getID(diskDriveSide))
- local passou = false
- local passou2 = false
- print("Gerente:"..Gerente)
- local lines = {}
- local hFile = fs.open("//configs/gerentes", "r")
- for lines in hFile.readLine do
- if Tog_Debug == true then print(lines) end -- DEBUG
- if lines == Gerente then passou = true end
- end
- hFile.close()
- if Tog_Debug == true then print("Debug 2") end -- DEBUG
- local lines = {}
- local hFile = fs.open("//configs/gerentes_id", "r")
- for lines in hFile.readLine do
- if lines == Disco_ID then passou2 = true end
- end
- hFile.close()
- if Tog_Debug == true then print("Debug 3") end -- DEBUG
- if passou == true and passou2 == true then
- disk.eject(diskDriveSide)
- print("Acesso aceito.")
- sleep(1.2)
- Tela()
- local passou1 = false
- repeat
- print("=== REGISTRO DE CAIXA ===")
- print("Digite o ID do Computador para ser Registrado como Caixa:")
- local ID_Caixa = read()
- if peripheral.isPresent(ler2) == true then
- if peripheral.getType(ler2) == "modem" then
- local passou_Caixa = false
- if fs.exists("//configs/caixas_registrados") == true then
- local lines = {}
- local hFile = fs.open("//configs/caixas_registrados", "r")
- for lines in hFile.readLine do
- if Tog_Debug == true then print(lines) end -- DEBUG
- if lines ~= ID_Caixa then passou_Caixa = true end
- end
- hFile.close()
- else passou_Caixa = true
- end
- if passou_Caixa == false then
- print("Caixa ja existe!")
- else
- print("Caixa nao registrado ainda. Deseja registar este ID: "..ID_Caixa.." ?(s/n)")
- local confirma = read()
- if confirma == "s" then
- passou1 = true
- print("Registrando...")
- local file = fs.open("//configs/caixas_registrados", "a")
- file.writeLine(ID_Caixa)
- file.close()
- timenow = os.time()
- timenow = textutils.formatTime(timenow, true)
- dianow = os.day()
- local file2 = fs.open("//Logs/Caixa_Reg_"..ID_Caixa, "w")
- file2.writeLine("Caixa Registrado")
- file2.writeLine("ID do Caixa: "..ID_Caixa)
- file2.writeLine("Registrado em:")
- file2.writeLine("Dia: "..dianow)
- file2.writeLine("Hora: "..timenow)
- file2.writeLine("Pelo Server ID: "..PC_ID)
- file2.writeLine("Pelo Gerente: "..Gerente)
- file2.close()
- print("ID: "..ID_Caixa.." registrado com sucesso!")
- sleep(2)
- shell.run("//startup")
- end
- end
- else
- print("Modem de internet nao encontrado no lado '"..ler2.."'.")
- sleep(2)
- end
- else
- print("Nenhum periferico encontrado!")
- sleep(1.2)
- end
- until passou1 == true
- end
- else
- print("Acesso rejeitado.")
- sleep(1.2)
- end
- else
- print("Nao tem nenhum disquete no Driver!")
- return
- end
Add Comment
Please, Sign In to add comment