Guest User

Security Card Writer

a guest
Apr 12th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. -- Security Card Writer
  2. -- Requires Security Card API
  3.  
  4. --checks if the card API is loaded If not tries to load it and if that fails throws an error
  5. if(not card)then
  6.     if(os.loadAPI("card")~=true)then
  7.         error("This program needs the security card API")
  8.     end
  9. end
  10. local event, side
  11. term.clear()
  12. term.setCursorPos(1,1)
  13. while true do
  14.     print("Please insert a disk to be written to")
  15.     --pullEventRaw stops them from pressing Ctrl-T to terminate
  16.     event, side = os.pullEventRaw("disk")
  17.     if disk.hasAudio(side) then
  18.         print("Wrong disk type")
  19.         print("Press any key to continue...")
  20.         os.pullEventRaw("key")
  21.     else
  22.         break
  23.     end
  24. end
  25.  
  26.  
  27. print("What should the base level be?")
  28. local lvl1 = read()
  29. print("What should the secondary level be?")
  30. local lvl2 = read()
  31. print("What should the password be?")
  32. local pass = read()
  33. term.scroll(1)
  34. term.write("Writing")
  35. textutils.slowPrint("...")
  36. card.setDiskLevel(side, lvl1, lvl2, pass)
  37. print("Card has been named:\n Level: "..lvl1.."-"..lvl2.." Card")
  38. print("Your new security card will be ejected now")
  39. disk.eject(side)
  40. os.unloadAPI("card")
  41. --Good Programming Practice :)
Advertisement
Add Comment
Please, Sign In to add comment