Advertisement
NuAoA

GetMods

Jun 8th, 2013
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.00 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 mod_array = {
  9. "Anon232"; --White
  10. "USCCoder"; --Orange
  11. "Canilsen"; --Magenta
  12. "Cynterea"; --LightBlue
  13. "Daebat"; --Yellow
  14. "Drehmini"; --Lime
  15. "Brendan09"; --Pink
  16. "Sonolumin"; --Gray
  17. "Sega5"; --LightGray
  18. "Awade33"; --Cyan
  19. "k"; --Purple
  20. "k"; --Blue
  21. "k"; --Brown
  22. "k"; --Green
  23. "k"; --Red
  24. "k"; --Black
  25. }
  26. if not fs.exists("wrap") then
  27.     print("Wrap API not found, downloading from http://pastebin.com/g5tBarus")
  28.     shell.run("pastebin get g5tBarus wrap")
  29. end
  30. if not fs.exists("Draw") then
  31.     print("Draw API not found, downloading from http://pastebin.com/3sAGiX7j")
  32.     shell.run("pastebin get 3sAGiX7j Draw")
  33. end
  34. os.loadAPI("wrap")
  35. os.loadAPI("Draw")
  36. mon = wrap.attach("monitor")
  37. for i=1,16 do
  38.         local temp_tab = {}
  39.         temp_tab["name"] = mod_array[i]
  40.         temp_tab["state"] = false
  41.         on_array[i] = temp_tab
  42. end
  43.  
  44. function deepcopy(orig)
  45.     local orig_type = type(orig)
  46.     local copy
  47.     if orig_type == 'table' then
  48.         copy = {}
  49.         for orig_key, orig_value in next, orig, nil do
  50.             copy[deepcopy(orig_key)] = deepcopy(orig_value)
  51.         end
  52.         setmetatable(copy, deepcopy(getmetatable(orig)))
  53.     else -- number, string, boolean, etc
  54.         copy = orig
  55.     end
  56.     return copy
  57. end      
  58.  
  59.  
  60. function getBroadcast()  
  61.     rednet.open(rednetFace)
  62.     while true do
  63.         local id,mess = rednet.receive()
  64.         if id == broadcastID then
  65.             local iter = 1
  66.             for word in string.gmatch(mess,"%S+") do
  67.                 on_array[iter]["name"] = string.match(word,"(%S+)|%S+")
  68.                 local onOff = string.match(word,"%S+|(%S+)")
  69.                 if onOff == "on" then
  70.                     on_array[iter]["state"] = true
  71.                 elseif onOff == "off" then
  72.                     on_array[iter]["state"] = false
  73.                 end            
  74.                 iter = iter+1
  75.             end
  76.             os.queueEvent("Update")
  77.         end
  78.     end    
  79. end
  80.  
  81. function update()
  82.     while true do
  83.         local event = os.pullEvent("Update")
  84.         local t_c,t_t = Draw.emptyScreen(mon)
  85.         Draw.tc(t_c,1,1,colors.brown,#t_c[1],#t_c)     
  86.         local iter = 2
  87.         Draw.tt(t_t,1,1,"Admins:")
  88.         for k,v in pairs(on_array) do          
  89.             if on_array[k]["name"] ~= "k" and on_array[k]["state"] then
  90.                 Draw.tt(t_t,2,iter,on_array[k]["name"].."(&"..Draw.getHexOf(colors.lime).."Online&"..Draw.getHexOf(colors.white)..")")
  91.                 iter = iter+1
  92.             end
  93.         end
  94.         for k,v in pairs(on_array) do          
  95.             if on_array[k]["name"] ~= "k" and not on_array[k]["state"] then
  96.                 Draw.tt(t_t,2,iter,on_array[k]["name"].."(&"..Draw.getHexOf(colors.red).."Offline&"..Draw.getHexOf(colors.white)..")")
  97.                 iter = iter+1
  98.             end
  99.         end        
  100.         Draw.draw(mon,t_c,1,1,colors.black,t_t)
  101.     end
  102. end
  103.  
  104. function antiHack()    
  105.         print("[AntiHack] Enabled")
  106.         while true do
  107.                 local event,side = os.pullEventRaw()          
  108.                 if event == "peripheral" then
  109.                         if peripheral.getType(side) == "drive" then
  110.                                 -- we got someone putting a drive next to the terminal
  111.                         elseif peripheral.getType(side) == "computer" then
  112.                                
  113.                         end
  114.                 elseif event == "disk" then
  115.                         if fs.exists("disk/startup") then
  116.                                 fs.delete("disk/startup")
  117.                                 disk.setLabel(side,"Broken Floppy")
  118.                         end
  119.                 elseif event == "terminate" then
  120.                         os.queueEvent("password")
  121.                 end
  122.         end            
  123. end
  124. function password()
  125.         while true do
  126.                 local event = os.pullEvent("password")
  127.                 sleep(0)
  128.                 term.clear()
  129.                 term.setCursorPos(1,1)
  130.                 if string.lower(read("*")) == "recordmods" then                
  131.                         shell.run("edit startup")
  132.                         os.reboot()
  133.                 end
  134.         end
  135. end
  136. parallel.waitForAll(update,getBroadcast,password)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement