Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m = peripheral.wrap("right")
- diskSide = "back"
- local username = ""
- local chunks = 0
- local ID = ""
- local password = {}
- local s = m.setCursorPos
- local b = m.setBackgroundColor
- local login_text = "Take the Card"
- local waittime = 0.1
- local drawed = false
- function openDisk()
- local exists = fs.exists("/disk/username")
- local exists2 = fs.exists("/disk/chunks")
- local exists3 = fs.exists("/disk/chunkID")
- if exists and exists2 and exists3 then
- local file = fs.open( "/disk/username", "r" )
- username = file.readLine()
- file.close()
- local file = fs.open( "/disk/chunks", "r" )
- chunks = file.readLine()
- chunks = tonumber(chunks)
- file.close()
- local file = fs.open( "/disk/chunkID", "r" )
- ID = file.readLine()
- file.close()
- for i = 1, chunks do
- local file = fs.open( "/disk/"..ID.."_"..tostring(i), "r")
- password[i] = file.readLine()
- file.close()
- end
- --m.clear()
- --m.setCursorPos(1,1)
- --m.write(username)
- --s(1,2)
- --m.write(chunks)
- --s(1,3)
- --m.write(ID)
- --s(1,1)
- local truePSW = ""
- for i = 1, chunks do
- truePSW = truePSW..password[i]
- end
- return truePSW
- else
- return false
- end
- end
- function drawT()
- m.setBackgroundColor(colors.white)
- s(2,3)
- local len = login_text:len()
- for i = 1, len+2 do
- s(1+i,2)
- m.write(" ")
- s(1+i, 3)
- m.write(" ")
- s(1+i, 4)
- m.write(" ")
- end
- s(3, 3)
- m.setTextColor(colors.black)
- m.write( login_text )
- end
- function menu(loaded)
- plusY = 21
- m.setBackgroundColor(colors.black)
- m.clear()
- s(2+plusY,2)
- m.setTextColor(colors.lime)
- local file = fs.exists("/disk/username")
- local second = fs.exists("/disk")
- loaded = loaded + 1
- if loaded > 8 then
- loaded = 8
- end
- if file then
- --drawDisk(plusY, loaded) -- Draw the disk
- if loaded == 8 then
- local v = openDisk()
- error(username.." "..v)
- -- Touch
- --local event, side, xP, yP = os.pullEvent("monitor_touch")
- else
- s(3,3)
- b(colors.black)
- m.write("Loading Disk")
- drawed = false
- end
- else
- drawDisk(plusY, 0)
- s(3,3)
- b(colors.black)
- if second then
- m.write("Invalid Disk")
- else
- m.write("Insert Disk")
- end
- loaded = 0
- end
- sleep(waittime)
- menu(loaded)
- end
- function drawDisk(plus, loaded)
- for i = 1, 8 do
- if i <= loaded then
- b(colors.white)
- else
- b(colors.gray)
- end
- s(3+plus, 1+i)
- if i == 1 then
- m.write(" ")
- else
- m.write(" ")
- end
- end
- end
- menu(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement