osirisgothra

anvi.coreprog.minefactory

Apr 10th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- ANVI.COREPROG-MINEFACTORY
  2. -- osirisgothra
  3. -- gabriel.sharp april.2017
  4. print("scanning...")
  5. local ifaces = {}
  6.  
  7. for i,name in pairs(peripheral.getNames()) do
  8.   if string.match(name,'transvector') then
  9.     print("adding machine to interfaces: ",name)
  10.     table.insert(ifaces,peripheral.wrap(name))
  11.   else
  12.     print("skipping: ",name)
  13.   end
  14. end
  15.  
  16. --- begin monitoring
  17. local mon = peripheral.wrap('monitor_134')
  18. local timeout = 2.5
  19.  
  20. print("entering monitoring loop...")
  21. while true do
  22.   ypos=1
  23.   mon.clear()
  24.   mon.setCursorPos(1,1)
  25.   mon.write("Name            Item          Complete")  
  26.   mon.setCursorPos(1,2)
  27.   mon.write("-------------------------------------------")
  28.   print("about to enter iteration...")
  29.   for i,x in pairs(ifaces) do
  30.    print("iteration of: ",i,x)
  31.    uname = tostring( x.getInvName() )
  32.    uitem = tostring( x.getStackInSlot(0).name )
  33.    ypos=ypos+1
  34.    mon.setCursorPos(1,ypos)
  35.    mon.clearLine()
  36.    mon.write(uname)
  37.    mon.setCursorPos(16,ypos)
  38.    mon.write(uitem)  
  39.    mon.setCursorPos(30,ypos)
  40.    mon.write(tostring(math.floor(x.getWorkMax()/x.getWorkDone()*100)))
  41.   end
  42.   sleep(timeout)
  43. end
Add Comment
Please, Sign In to add comment