Advertisement
jc2xs

AEAuto

May 17th, 2014
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.25 KB | None | 0 0
  1. --  AEAutoCraft
  2. --  Written by Henry Link for minecraft 1.6.4 (DW20 pack)
  3. --  Original pastebin aTvRPuJt
  4.  
  5. --  Processing indicators
  6. --  Use a redstone signal to trigger lamps on/off to indicate if something is being made
  7. rl = "left"  -- rl = red lamp - turns on when there is crafting in progress
  8. gl = "right"  --  gl = green lamp - turns on when there is no crafting
  9. redstone.setOutput(gl, true)
  10.  
  11. --  Peripheral wrap the crafting terminal
  12. --    Note this could be almost any AE block
  13. cm = peripheral.wrap("bottom")
  14.  
  15. -- Define the array of items you want to keep in stock
  16. --   qty is the amount to be made
  17. --   stock is the amount to kept in stock
  18. --   current needs to be defined but the scanCurrent function will fill that data with current inventory numbers
  19. itemList = {}
  20. itemList[1] =  {["name"] = "Glass", ["id"] = 20, ["dmg"] = 0, ["qty"] = 0, ["stock"] = 256, ["current"] = 0}
  21. itemList[2] =  {["name"] = "Nether Quartz Dust", ["id"] = 4362, ["dmg"] = 22, ["qty"] = 0, ["stock"] = 128, ["current"] = 0}
  22. itemList[3] =  {["name"] = "Silicon", ["id"] = 4362, ["dmg"] = 13, ["qty"] = 0, ["stock"] = 32, ["current"] = 0}
  23. itemList[4] =  {["name"] = "Basic Processor", ["id"] = 4362, ["dmg"] = 18, ["qty"] = 0, ["stock"] = 32, ["current"] = 0}
  24. itemList[5] =  {["name"] = "Advanced Processor", ["id"] = 4362, ["dmg"] = 19, ["qty"] = 0, ["stock"] = 16, ["current"] = 0}
  25. itemList[6] =  {["name"] = "Fluix Dust", ["id"] = 4362, ["dmg"] = 14, ["qty"] = 0, ["stock"] = 32, ["current"] = 0}
  26. itemList[7] =  {["name"] = "Fluix Crystal", ["id"] = 4362, ["dmg"] = 23, ["qty"] = 0, ["stock"] = 16, ["current"] = 0}
  27. itemList[8] =  {["name"] = "Fluix Pearl", ["id"] = 4362, ["dmg"] = 24, ["qty"] = 0, ["stock"] = 16, ["current"] = 0}
  28. itemList[9] =  {["name"] = "Conversion Matix", ["id"] = 4362, ["dmg"] = 0, ["qty"] = 0, ["stock"] = 16, ["current"] = 0}
  29. itemList[10] =  {["name"] = "ME Cable", ["id"] = 852, ["dmg"] = 14, ["qty"] = 0, ["stock"] = 64, ["current"] = 0}
  30. itemList[11] =  {["name"] = "Blank Pattern", ["id"] = 4362, ["dmg"] = 16, ["qty"] = 0, ["stock"] = 64, ["current"] = 0}
  31. itemList[12] =  {["name"] = "ME Interface", ["id"] = 851, ["dmg"] = 8, ["qty"] = 0, ["stock"] = 16, ["current"] = 0}
  32. itemList[13] =  {["name"] = "ME Basic Import Bus", ["id"] = 853, ["dmg"] = 3, ["qty"] = 0, ["stock"] = 8, ["current"] = 0}
  33. itemList[14] =  {["name"] = "ME Basic Export Bus", ["id"] = 853, ["dmg"] = 2, ["qty"] = 0, ["stock"] = 8, ["current"] = 0}
  34. itemList[15] =  {["name"] = "ME Precision Export Bus", ["id"] = 852, ["dmg"] = 0, ["qty"] = 0, ["stock"] = 4, ["current"] = 0}
  35. itemList[16] =  {["name"] = "ME Storage Bus", ["id"] = 852, ["dmg"] = 9, ["qty"] = 0, ["stock"] = 4, ["current"] = 0}
  36.  
  37. itemList[17] =  {["name"] = "Blizz Powder", ["id"] = 20264, ["dmg"] = 1025, ["qty"] = 0, ["stock"] = 64, ["current"] = 0}
  38. itemList[18] =  {["name"] = "Pyrotheum Dust", ["id"] = 20264, ["dmg"] = 165, ["qty"] = 0, ["stock"] = 64, ["current"] = 0}
  39. itemList[19] =  {["name"] = "Resonant Ender Bucket", ["id"] = 20259, ["dmg"] = 2, ["qty"] = 0, ["stock"] = 32, ["current"] = 0}
  40. itemList[20] =  {["name"] = "Pulverized Tin", ["id"] = 20264, ["dmg"] = 33, ["qty"] = 0, ["stock"] = 64, ["current"] = 0}
  41. itemList[21] =  {["name"] = "Cinnabar", ["id"] = 20264, ["dmg"] = 130, ["qty"] = 0, ["stock"] = 64, ["current"] = 0}
  42. itemList[22] =  {["name"] = "Pulverized Shiny Metal", ["id"] = 20264, ["dmg"] = 33, ["qty"] = 0, ["stock"] = 64, ["current"] = 0}
  43. itemList[23] =  {["name"] = "Enderium Blend", ["id"] = 20264, ["dmg"] = 42, ["qty"] = 0, ["stock"] = 64, ["current"] = 0}
  44. itemList[24] =  {["name"] = "Enderium Ingot", ["id"] = 20264, ["dmg"] = 74, ["qty"] = 0, ["stock"] = 32, ["current"] = 0}
  45. itemList[25] =  {["name"] = "Pulverized Obsidian", ["id"] = 20264, ["dmg"] = 3, ["qty"] = 0, ["stock"] = 64, ["current"] = 0}
  46. itemList[26] =  {["name"] = "Hardened Glass", ["id"] = 2013, ["dmg"] = 0, ["qty"] = 0, ["stock"] = 32, ["current"] = 0}
  47. itemList[27] =  {["name"] = "Redstone Energy Conduit", ["id"] = 20278, ["dmg"] = 2, ["qty"] = 0, ["stock"] = 32, ["current"] = 0}
  48. itemList[28] =  {["name"] = "Impulse Itemduct", ["id"] = 20278, ["dmg"] = 4098, ["qty"] = 0, ["stock"] = 32, ["current"] = 0}
  49. itemList[29] =  {["name"] = "Fluiduct", ["id"] = 20278, ["dmg"] = 2048, ["qty"] = 0, ["stock"] = 32, ["current"] = 0}
  50. itemList[30] =  {["name"] = "Pneumatci Servo", ["id"] = 20264, ["dmg"] = 192, ["qty"] = 0, ["stock"] = 4, ["current"] = 0}
  51.  
  52. itemList[31] =  {["name"] = "Pulverized Coal", ["id"] = 20264, ["dmg"] = 2, ["qty"] = 0, ["stock"] = 64, ["current"] = 0}
  53. itemList[32] =  {["name"] = "Steel Ingot", ["id"] = 7798, ["dmg"] = 0, ["qty"] = 0, ["stock"] = 128, ["current"] = 0}
  54. itemList[33] =  {["name"] = "Steel Plate", ["id"] = 7802, ["dmg"] = 1, ["qty"] = 0, ["stock"] = 64, ["current"] = 0}
  55.  
  56.  
  57.  
  58. -- Get the current inventory and place it into the array
  59. function scanCurrent()
  60.    for i, data in pairs(itemList) do
  61.       -- c is the current count of the item we are currently on in the array
  62.       c = cm.countOfItemType(itemList[i]["id"],itemList[i]["dmg"])
  63.       -- Store it back into the array
  64.       itemList[i]["current"] = c
  65.       --print(itemList[i]["name"].. " = " .. c)
  66.    end
  67. end
  68.  
  69. -- Main loop
  70.  
  71. while true do
  72.  
  73.   -- Scan our inventory
  74.   print("Scanning Inventory...")
  75.   sleep(2)
  76.   scanCurrent()
  77.   -- Now loop through each item and see if anything needs to be crafted
  78.   for i, data in pairs(itemList) do
  79.     if itemList[i]["current"] < itemList[i]["stock"] then
  80.       -- Found an item the needs crafting.  Figure out how many
  81.       itemList[i]["qty"] =  itemList[i]["stock"] - itemList[i]["current"]
  82.       print("Need to make " .. itemList[i]["qty"] .. " of " .. itemList[i]["name"])
  83.       -- Trigger AE to craft it
  84.       cm.requestCrafting(itemList[i])
  85.       redstone.setOutput(gl, false)
  86.       redstone.setOutput(rl, true)
  87.       -- Display crafting status and wait for the item to complete
  88.       while itemList[i]["current"] < itemList[i]["stock"] do
  89.         c = cm.countOfItemType(itemList[i]["id"],itemList[i]["dmg"])
  90.         itemList[i]["current"] = c
  91.         sleep(4)
  92.         print("  Waiting for " .. itemList[i]["stock"] - itemList[i]["current"]  .. " of " .. itemList[i]["name"] .. " to be made")
  93.       end
  94.       redstone.setOutput(gl, true)
  95.       redstone.setOutput(rl, false)
  96.     end
  97.   end
  98.   sleep(10)
  99. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement