jc2xs

AE Crystal Grower1.12

Dec 28th, 2014 (edited)
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Labels and variables for the items we need for crystal growth
  2. -- Fluix Crystal
  3.    lblNetherQuartz = "Nether Quartz"
  4.    bNQ = false -- do we have Nether Quartz
  5.    lblRedstone = "Redstone"
  6.    bR = false -- do we have Redstone
  7.    lblChargedCertus = "Charged Certus Quartz Crystal"
  8.    bCC = false -- do we have Charged Certus
  9. -- Pure Certus Quartz
  10.    lblCertusSeed = "Certus Quartz Seed"
  11.    bCS = false -- do we have Certus Quartz Seed
  12. -- Pure Fluix Crystal
  13.    lblFluixSeed = "Fluix Seed"
  14. -- Pure Nether Quartz
  15.    lblNQuartzSeed = "Nether Quartz Seed"
  16.    bFS = false -- dw we have Fluix Seed
  17. -- Side of the turtle the chest is on
  18. --     This requires the chest to be in front of the turtle or on top of the turtle.
  19. --     Edit code in function fMoveOne (turtle.drop or turtle.dropUp)
  20.    lblChest = "front"
  21.    lblPushDir = "south"
  22. -- Side of the turtle used to turn off energy
  23.    lblRS = "back"
  24.    
  25.  
  26.  
  27. pChest = peripheral.wrap(lblChest)
  28.  
  29. --  This function will scan the chest and detect what ingredients are located in it
  30. function fCheckChest()
  31.   -- Start by setting all of the ingredients to false
  32.   bNQ = false -- Nether Quartz
  33.   bR = false -- Redstone
  34.   bCC = false -- Charged Certus
  35.   bCS = false -- Certus Seed
  36.   bFS = false -- Fluix Seed
  37.   bNQS = false -- Nether Quartz Seed
  38.   cSize = pChest.size()  -- number of slots in the chest
  39.   --print("cSize = "..cSize)
  40.   for slot = 1, cSize do
  41.     --print("slot = "..slot)
  42.     data = pChest.getItemMeta(slot)
  43.     if data == nil then
  44.       itemName = "No item in slot"
  45.     else
  46.       itemName = data["displayName"]
  47.       print(itemName)
  48.     end
  49.     if itemName == lblNetherQuartz then
  50.       bNQ = true
  51.       print("Found Nether Quartz")
  52.       slotNQ = slot
  53.     end -- if
  54.     if itemName == lblRedstone then
  55.       bR = true
  56.       print("Found Redstone")
  57.       slotR = slot
  58.     end -- if
  59.     if itemName == lblChargedCertus then
  60.       bCC = true
  61.       print("Found Charged Certus")
  62.       slotCC = slot
  63.     end -- if
  64.     if itemName == lblCertusSeed then
  65.       bCS = true
  66.       print("Found Certus Seed")
  67.       slotCS = slot
  68.     end -- if
  69.     if itemName == lblFluixSeed then
  70.       bFS = true
  71.       print("Found Fluix Seed")
  72.       slotFS = slot
  73.     end -- if
  74.     if itemName == lblNQuartzSeed then
  75.       bNQS = true
  76.       print("Found Nether Quartz Seed")
  77.       slotNQS = slot
  78.     end -- if
  79.   end -- for
  80. end -- function
  81.  
  82. -- This routine will drop the seeds and turn on the accelerators
  83. -- It will aslo check on the seed growth and turn off the accelerators when done
  84. function fGrowSeeds()
  85.     turtle.dropDown()
  86.     redstone.setAnalogOutput(lblRS, 15)
  87.     os.sleep(30) -- wait 30 seconds
  88.     while turtle.suckDown() do
  89.       turtle.dropDown()
  90.       os.sleep(30)
  91.     end -- do
  92.     redstone.setAnalogOutput(lblRS, 0)
  93. end -- function
  94.  
  95. -- This routine will pull one item out of the chest and drop it into the water below
  96. function fMoveOne(moveSlot)
  97.   pChest.drop(moveSlot, 1, "down")
  98.     --pushItemIntoSlot(lblPushDir, moveSlot)
  99. end -- function
  100.  
  101. -- This routine will check to see if we have a crafting operation to perform
  102. function fCheck4Work()
  103.   if bFS then
  104.     print("Make Pure Fluix")
  105.     pChest.drop(slotFS, 64, "down")
  106.     fGrowSeeds()
  107.   elseif bCS then
  108.     print("Make Pure Certus")
  109.     pChest.drop(slotCS, 64, "down")
  110.     fGrowSeeds()
  111.   elseif bNQS then
  112.     print("Make Pure Nether Quartz")
  113.     pChest.drop(slotNQS, 64, "down")
  114.     fGrowSeeds()
  115.   elseif (bNQ and bR and bCC) then
  116.     print("Make Fluix")
  117.       fMoveOne(slotNQ)
  118.       fMoveOne(slotR)
  119.       fMoveOne(slotCC)
  120. --  else
  121. --    print("Nothing to make")
  122.   end -- if
  123. end -- function
  124.  
  125. while true do
  126.   fCheckChest()
  127.   fCheck4Work()
  128.   os.sleep(1)  -- wait one seconds between checks
  129. end -- program
Add Comment
Please, Sign In to add comment