ZNZNCOOP

Scanner

Mar 16th, 2015
315
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local Buffer= {}
  2. local Object= {}
  3. local goal= {"computer","monitor","drive","printer"}
  4. local limit= 20000
  5. local X,Y= term.getSize()
  6.  
  7. Object[1]= {}
  8. Object[1].stage= 0
  9. Object[1].limit= 10
  10.  
  11. function main(update)
  12.    scanner(update)
  13. end
  14.  
  15. function scanner(update)
  16.    if (update) then
  17.       gCount,count= 0,0
  18.       while true do
  19.          for q=1,#goal do
  20.             h= peripheral.wrap(goal[q].."_"..gCount)
  21.             if (h ~= nil) then
  22.                Buffer[#Buffer+1]= {}
  23.                Buffer[#Buffer].name= goal[q].."_"..gCount
  24.             end
  25.          end
  26.          gCount= gCount+1
  27.          count= count+1
  28.          per= gCount/(limit/(X-8))
  29.          Object[1].stage= math.ceil(per)
  30.          if (count >= 500) then draw("Scanning",".",1,1)  count= 0 sleep(0) end
  31.          if (gCount >= limit) then gCount= 0 Buffer= {} end
  32.       end
  33.    else
  34.    end
  35. end
  36.  
  37. function draw(Text,simbol,x,y)
  38.    term.clear()
  39.    term.setCursorPos(x,y)
  40.    io.write(Text)
  41.    for i=1,Object[1].stage do
  42.       io.write(simbol)
  43.    end
  44.    print()
  45.    --print(Object[1].stage)
  46.    for i=1,X do
  47.       io.write("_")
  48.    end
  49.    if (#Buffer > 0) then
  50.       for i=1,#Buffer do
  51.          print(Buffer[i].name)
  52.       end
  53.    end
  54. end
  55.  
  56. main(true)
RAW Paste Data