This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Bossbrick's profile picture

Security key help

Started by Bossbrick, 31 December 2014 - 07:47 AM
Bossbrick #1
Posted 31 December 2014 - 08:47 AM
This is my first 100% "me" project and this one if/else statement is getting the better of me and will always go else when I seem to meet all the demands. Maybe someone else can see the error that I cannot.
Computer startup:

os.pullEvent = os.pullEventRaw
while true do
if disk.hasData("bottom") == true then
  disk.eject("bottom")
end
term.clear()
print("place key, say OK") -- I place key in disk drive, type OK --
input = read()
if input == "OK" and fs.exists("disk/str") == true then
  shell.run("disk/str")
else
  term.clear()
  term.setTextColor(colors.red)
  print("Credentials Incorrect")
  disk.eject("bottom")
  print("Shutting down")
  os.sleep(2)
  os.reboot(1)
end
end  

Key:str

shell.run("startup")

my startup is on the key rather than the rom, but can only be accessed through a program called "str". Thanks for reviewing this.
Edited on 31 December 2014 - 03:49 PM
Dragon53535 #2
Posted 31 December 2014 - 11:35 PM
I'm assuming that it's not finding "disk/str"?

Perhaps it's under disk2/str if you had multiple drives.

print("place key, say OK") -- I place key in disk drive, type OK --
input = read()
local diskPath = fs.combine(disk.getMountPath("bottom"),"str") --#This turns it into "disk/str" However it gets the actual path if for some reason it's not just disk/str perhaps it's
--#disk2/str and it will find it
if input == "OK" and fs.exists(diskPath) == true then
  shell.run(diskPath)
else
  term.clear()
  term.setTextColor(colors.red)
  print("Credentials Incorrect")
  disk.eject("bottom")
  print("Shutting down")
  os.sleep(2)
  os.reboot(1)
end
Edited on 31 December 2014 - 10:35 PM