kizz12

master

Apr 21st, 2015
827
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | None | 0 0
  1.  --local osEvent=os.pullEvent
  2. --os.pullEvent=os.pullEventRaw
  3. function protect()
  4.     local combine = fs.combine
  5.     local oldFs = fs.open
  6.     --print'OS Protect active!'
  7.     fs.open = function(path,...)
  8.         if combine("/",path) == "rom/programs/edit" then
  9.             --print'Failed to call edit!'
  10.             return
  11.         end
  12.         if combine("/",path) == "rom/programs/delete" then
  13.             --print'Failed to call delete!'
  14.             return
  15.         end
  16.         if combine("/",path) ~= "rom/programs/delete" then
  17.             return oldFs(path,...)
  18.         end
  19.     end
  20. end
  21.  
  22.  
  23. function logout()
  24.     timetor=300
  25.     while timetor > 0 do
  26.         term.clear()
  27.         term.setCursorPos(1,1)
  28.         timetor=timetor-1
  29.         print('Welcome OP. System Online. Restarting in '..timetor..' seconds.')
  30.         sleep(.95)
  31.     end
  32.     os.reboot()
  33. end
  34.  
  35. function listener()
  36.     while true do      
  37.         eventExtend,timer = os.pullEvent("extendme")
  38.         local typeCheck=type(timer)
  39.         if typeCheck=="number" then
  40.             if eventExtend == "extendme" and timer > 0 then
  41.                 print("Extending time!")
  42.                 timetor=timetor+timer
  43.             end
  44.         else
  45.             sleep(2)
  46.             print'Invalid choice.'
  47.         end
  48.        
  49.     end
  50. end
  51.  
  52.  
  53.  
  54. parallel.waitForAll(listener,logout,protect)
  55. os.pullEvent=osEvent
Advertisement
Add Comment
Please, Sign In to add comment