Advertisement
Guest User

Tess

a guest
May 4th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.48 KB | None | 0 0
  1. tess = peripheral.wrap("bottom")
  2. mon = peripheral.wrap("top")
  3. pwr = peripheral.wrap("right")
  4. tessDump = peripheral.wrap("tile_thermalexpansion_ender_tesseract_name_1")
  5. monTable = peripheral.wrap("monitor_6")
  6. freq = tess.getFrequency()
  7. local startPwr = pwr.getEnergyStored()
  8. function getNow(pwr_)
  9.   local current = pwr_.getEnergyStored()
  10.   pwrTaken = current - startPwr
  11. end
  12.  
  13. mon.clear()
  14. mon.setCursorPos(2,2)
  15. mon.setTextColor(2)
  16. mon.write("Freq: ")
  17. mon.setCursorPos(13,2)
  18. mon.write("Status: ")
  19. mon.setCursorPos(1,4)
  20. mon.write("------------------------------")
  21. mon.setCursorPos(2,6)
  22. mon.write("Type: ")
  23. mon.setCursorPos(7,9)
  24. mon.write("Drained: ")
  25.  
  26. monTable.clear()
  27. monTable.setCursorPos(2,2)
  28. monTable.setTextColor(2)
  29. monTable.write("Frequency:        Drained:")
  30. monTable.setCursorPos(1,3)
  31. monTable.write("--------------------------------")
  32.  
  33. print("Initial: ", startPwr)
  34. while(true) do
  35.   for i = 1, 999 do
  36.     tess.setFrequency(i)
  37.     print("Testing frequency: ", i)
  38.     mon.setCursorPos(7,2)
  39.     mon.setTextColor(1)
  40.     mon.write(i)
  41.     mon.setCursorPos(20,2)
  42.     mon.write("Searching")
  43.     getNow(pwr)
  44.    
  45.     local runPwr = pwr.getEnergyStored()
  46.     j = 1
  47.     sleep(1)
  48.    
  49.     if runPwr ~= pwr.getEnergyStored() then
  50.       print("Change detected: ", runPwr)
  51.      
  52.      
  53.       getNow(pwr)
  54.       runPwr = pwr.getEnergyStored()
  55.       local startVal = pwr.getEnergyStored()
  56.       local pwrDrained = 0
  57.      
  58.      
  59.       while(true) do
  60.         pwrDrained = runPwr - startVal
  61.         print("Found Power!! Now draining. ", j)
  62.         sleep(0.5)
  63.         j = j+1
  64.         if runPwr == pwr.getEnergyStored() then
  65.           print("Power Drained.")
  66.          
  67.           mon.setCursorPos(20,2)
  68.           mon.setTextColor(16384)
  69.           mon.write("Drained. ")
  70.          
  71.           getNow(pwr)
  72.           sleep(2)
  73.           break
  74.         else
  75.           runPwr = pwr.getEnergyStored()
  76.           print("Draining.", j)
  77.           sleep(0.5)
  78.           mon.setCursorPos(20,2)
  79.           mon.setTextColor(32)
  80.           mon.write("Draining ")
  81.           mon.setCursorPos(16,9)
  82.           mon.setTextColor(521)
  83.           mon.write(pwrDrained)
  84.         end
  85.       end
  86.     end
  87.    
  88.     if pwr.getEnergyStored() == pwr.getMaxEnergyStored() then
  89.      tess.setRedstoneControl(1)
  90.      mon.setCursorPos(20,2)
  91.      mon.setTextColor(2048)
  92.      mon.write("Pwr Dump ")
  93.      sleep(50)
  94.      tess.setRedstoneControl(2)
  95.     else
  96.      tess.setRedstoneControl(2)
  97.     end  
  98.   end
  99. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement