Advertisement
NuAoA

Rules

Jun 8th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. --UpdateMods
  2. --NuAoA
  3.  
  4. local on_array = {}
  5. os.pullEvent = os.pullEventRaw
  6. local rednetFace = "top"
  7. local broadcastID = 3
  8. local list = {
  9. "";
  10. "";
  11. "";
  12. "";
  13. "";
  14. }
  15. if not fs.exists("wrap") then
  16. print("Wrap API not found, downloading from http://pastebin.com/g5tBarus")
  17. shell.run("pastebin get g5tBarus wrap")
  18. end
  19. if not fs.exists("Draw") then
  20. print("Draw API not found, downloading from http://pastebin.com/3sAGiX7j")
  21. shell.run("pastebin get 3sAGiX7j Draw")
  22. end
  23. os.loadAPI("wrap")
  24. os.loadAPI("Draw")
  25. mon = wrap.attach("monitor")
  26. for i=1,16 do
  27. local temp_tab = {}
  28. temp_tab["name"] = mod_array[i]
  29. temp_tab["state"] = false
  30. on_array[i] = temp_tab
  31. end
  32.  
  33. function deepcopy(orig)
  34. local orig_type = type(orig)
  35. local copy
  36. if orig_type == 'table' then
  37. copy = {}
  38. for orig_key, orig_value in next, orig, nil do
  39. copy[deepcopy(orig_key)] = deepcopy(orig_value)
  40. end
  41. setmetatable(copy, deepcopy(getmetatable(orig)))
  42. else -- number, string, boolean, etc
  43. copy = orig
  44. end
  45. return copy
  46. end
  47.  
  48.  
  49. function getBroadcast()
  50. rednet.open(rednetFace)
  51. while true do
  52. local id,mess = rednet.receive()
  53. if id == broadcastID then
  54. local iter = 1
  55. for word in string.gmatch(mess,"%S+") do
  56. on_array[iter]["name"] = string.match(word,"(%S+)|%S+")
  57. local onOff = string.match(word,"%S+|(%S+)")
  58. if onOff == "on" then
  59. on_array[iter]["state"] = true
  60. elseif onOff == "off" then
  61. on_array[iter]["state"] = false
  62. end
  63. iter = iter+1
  64. end
  65. os.queueEvent("Update")
  66. end
  67. end
  68. end
  69.  
  70. function update()
  71. while true do
  72. local event = os.pullEvent("Update")
  73. local t_c,t_t = Draw.emptyScreen(mon)
  74. Draw.tc(t_c,1,1,colors.brown,#t_c[1],#t_c)
  75. for i=1,#list do
  76. Draw.tt(t_t,1,i,list[i])
  77. end
  78. Draw.draw(mon,t_c,1,1,colors.black,t_t)
  79. end
  80. end
  81.  
  82. function antiHack()
  83. print("[AntiHack] Enabled")
  84. while true do
  85. local event,side = os.pullEventRaw()
  86. if event == "peripheral" then
  87. if peripheral.getType(side) == "drive" then
  88. -- we got someone putting a drive next to the terminal
  89. elseif peripheral.getType(side) == "computer" then
  90.  
  91. end
  92. elseif event == "disk" then
  93. if fs.exists("disk/startup") then
  94. fs.delete("disk/startup")
  95. disk.setLabel(side,"Broken Floppy")
  96. end
  97. elseif event == "terminate" then
  98. os.queueEvent("password")
  99. end
  100. end
  101. end
  102. function password()
  103. while true do
  104. local event = os.pullEvent("password")
  105. sleep(0)
  106. term.clear()
  107. term.setCursorPos(1,1)
  108. if string.lower(read("*")) == "recordmods" then
  109. shell.run("edit startup")
  110. os.reboot()
  111. end
  112. end
  113. end
  114. function reUpdate()
  115. while true do
  116. sleep(10)
  117. os.queueEvent("Update")
  118. end
  119. end
  120. parallel.waitForAll(update,getBroadcast,password,reUpdate)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement