Posted 10 April 2018 - 10:40 PM
So I have this program I've been working on but now I've run into a problem with the function disk() not properly reading the disk right. Its suppose to read the file on the disk which contains the Table of the same on the computer. It opens both of them reads them and then is suppose to compare them and either grant you access or deny it. And all it does is deny it..
This is just the one spot I'm having trouble with.
I'd rather not paste all of it haha.
Solved.
local Tbe = {}
function Disk()
while true do
local driveSide
for _, side in ipairs(rs.getSides()) do
if peripheral.isPresent(side) and peripheral.getType(side) == "drive" then
driveSide = side
break
end
end
Login()
D = os.pullEvent()
Page.setCursorPos(17, 10)
Page.write("checking...")
sleep(0.2)
if disk.hasData(driveSide) == true then
Page.setTextColor(colors.green)
Page.setCursorPos(17, 10)
Page.write("Disk inserted!")
sleep(0.2)
if fs.exists("disk/USERS.txt") then
local Dbe = {}
d = fs.open("disk/USERS.txt","r")
Dbe = textutils.unserialize(d.readAll())
Dpass = Dbe.pass
side1 = Dbe.side
s = fs.open("saves/USERS.txt","r")
Tbe = textutils.unserialize(s.readAll())
pass1 = Tbe.pass
s.close()
d.close()
if (Dpass == pass1) then
disk.eject(driveSide)
pass()
else
Inv()
P()
end
else
disk.eject(driveSide)
Page.setCursorPos(17, 10)
Page.write("Invaild disk type!")
sleep(0.5)
P()
end
else
Page.setCursorPos(17,10)
Page.write(" no disk is inserterd.")
sleep(1)
P()
end
end
end
This is just the one spot I'm having trouble with.
I'd rather not paste all of it haha.
Solved.
Edited on 10 April 2018 - 10:32 PM