Guest User

Untitled

a guest
Aug 23rd, 2013
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. --variables
  2. local loadPath = "locker/locked"
  3. local prog = shell.getRunningProgram()
  4. local locked = {"startup"}
  5. local pass = "test"
  6. -- restore functions
  7. local fsOpen = fs.open
  8. local fsDelte = fs.delete
  9.  
  10.  
  11. table.insert(locked, prog)
  12. -- functions
  13. function clear()
  14. term.clear()
  15. term.setCursorPos(1,1)
  16. end
  17. function cPrint(str)
  18. w,h = term.getSize()
  19. local x,y = term.getCursorPos()
  20. term.setCursorPos(math.ceil((w+1)/2 - #str/2), y)
  21. print(str)
  22. end
  23. function password(file)
  24. print("You Can Enter A Password To Undo This")
  25. write("Enter Password: ")
  26. if pass == read() then
  27. -- remove program from locked
  28. for k, v in pairs(locked) do
  29. if v == file then
  30. table.remove(locked, k)
  31. end
  32. end
  33. print("Program Unlocked!")
  34. lock()
  35. end
  36. end
  37.  
  38.  
  39. function load() -- continue later
  40.  
  41. end
  42. function lock()
  43. -- open
  44. fs.open = function(file, mode)
  45. for _, v in pairs(locked) do
  46. if file == v then
  47. clear()
  48. cPrint("This Program Has Been Locked\nYou Cannot Open It!")
  49. password(v)
  50. return false
  51. end
  52. end
  53. return fsOpen(file,mode)
  54. end
  55.  
  56. -- delete
  57. fs.delete = function(file)
  58. for _, v in pairs(locked) do
  59. if file == v then
  60. clear()
  61. cPrint("This Program Has Been Locked \nYou Cannot Delete It!")
  62. password()
  63. return false
  64. end
  65. end
  66. return fsDelete(file)
  67. end
  68.  
  69.  
  70.  
  71. end
  72. lock()
Advertisement
Add Comment
Please, Sign In to add comment