SHARE
TWEET

AE2 Crystal Grower

HydrantHunter Nov 27th, 2014 (edited) 571 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[ AE2 Crystal Grower ]]--
  2. --[[ http://www.computercraft.info/forums2/index.php?/topic/20130-ae2-pure-certus-quartz-or-fluix-grower/ ]]--
  3.  
  4. local iteration = 0
  5. rs.setOutput("back", false)   -- turn off redstone
  6. turtle.suckDown()             -- clear the pool
  7. term.setBackgroundColor(colors.black)
  8. term.setTextColor(colors.white)
  9. term.clear()
  10. term.setCursorPos(2, 2)
  11.  
  12. local function checkForSource() -- If anything is in slot 13-16 we have crystals for comparison
  13.   for i = 13, 16 do
  14.     if turtle.getItemCount(i) > 0 then return true end
  15.   end
  16.   return false
  17. end
  18.  
  19. local function checkForWork() -- If anything is in slot 1-12 we have work to do
  20.   for i = 1, 12 do
  21.     if turtle.getItemCount(i) > 0 then return true end
  22.   end
  23.   return false
  24. end
  25.  
  26. local function checkWorkStatus() -- Check the status of the work in progress
  27.   turtle.suckDown()              -- Anything unfinished will be found by the
  28.   for i = 1, 12 do               -- next checkForWork cycle
  29.     turtle.select(i)
  30.     for j = 13, 16 do
  31.       if turtle.compareTo(j) then turtle.dropUp() end
  32.     end
  33.   end
  34. end
  35.  
  36. if not checkForSource() then
  37.   term.write("No comparison crystals")
  38.   term.setCursorPos(1, 4)
  39.   return
  40. end
  41.  
  42. term.write("Processing crystals...")
  43. term.setCursorPos(2, 4)
  44. term.write("Iteration")
  45.  
  46. while true do -- Main loop
  47.   iteration = iteration + 1
  48.   term.setCursorPos(12, 4)
  49.   if checkForWork() then       -- Now we can turn on the accelerators
  50.     rs.setOutput("back", true) -- and run a cycle
  51.     for i = 1, 12 do
  52.       turtle.select(i)
  53.       turtle.dropDown()        -- Since we have work, drop the items
  54.       term.write(tostring(iteration) .. ": working")
  55.     end
  56.     os.sleep(60)               -- now wait a bit for it to process
  57.     checkWorkStatus()
  58.   else
  59.     rs.setOutput("back", false)
  60.     term.write(tostring(iteration) .. ": idle   ")
  61.     os.sleep(6)
  62.   end
  63. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top