mah17

AE Crystal Checker

Nov 7th, 2014
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.80 KB | None | 0 0
  1. -- AE Crystal Checking Script
  2. --  Is the crystal crystally yet? Or is it still seedy? LETS FIND OUT!
  3. --  (The turtle must be placed directly above the water!)
  4. --  (The chest must be placed directly above the turtle!)
  5.  
  6. --<< Global configs >>--
  7.  
  8. -- Time the script pauses before checking the crystals
  9. local sleepTime = 20
  10.  
  11. -- Pairs of values: 1st is the name, second is the damage value.
  12. -- Gotten by putting item in selected slot and running turtle.getItemDetail()
  13. local finalForm = {
  14.   "appliedenergistics2:item.ItemMultiMaterial", 10, --Certus
  15.   "appliedenergistics2:item.ItemMultiMaterial", 11, --Nether
  16.   "appliedenergistics2:item.ItemMultiMaterial", 7, --Fluix Raw
  17.   "appliedenergistics2:item.ItemMultiMaterial", 12 --Fluix Pure
  18. }
  19.  
  20. -- Output info for user
  21. print("AE Crystal Checker")
  22. print("------------------")
  23. print()
  24. print("Press q to quit...")
  25.  
  26. -- Function that returns true if the selected item is in the table, false if not
  27. function isFinalForm()
  28.   local data = turtle.getItemDetail()
  29.   if data == nil then
  30.     return false
  31.   end
  32.  
  33.   for i=1,#finalForm,2 do
  34.     if data.name == finalForm[i] then
  35.       if data.damage == finalForm[i+1] then
  36.         return true
  37.       end
  38.     end
  39.   end
  40.  
  41.   return false
  42. end
  43.  
  44. -- Main
  45.  
  46. -- Setting up
  47. local timer = os.startTimer(sleepTime)
  48.  
  49. while true do
  50.   local event, edata = os.pullEvent()
  51.  
  52.   if event == "timer" and edata == timer then
  53.     -- This is the timer we started, let's go!
  54.    
  55.     while turtle.suckDown() do end
  56.     for i=1,16 do
  57.       turtle.select(i)
  58.       if isFinalForm() then
  59.         turtle.dropUp()
  60.       else
  61.         turtle.dropDown()
  62.       end
  63.     end
  64.     turtle.select(1)
  65.    
  66.     -- Restart the timer
  67.     timer = os.startTimer(sleepTime)
  68.    
  69.   elseif event == "key" and edata == 16 then
  70.     break
  71.   end
  72. end
Advertisement
Add Comment
Please, Sign In to add comment