Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.74 KB | None | 0 0
  1. -- BM Altar Automation by Apoc
  2. -- v1.0 - 2/20/2016
  3. -- Initial Release
  4.  
  5. local altarPeripheralName = "bloodmagic:altar_0"
  6. local altarBufferChestDir = "west"
  7. local altarBufferChestName = "minecraft:chest_0"
  8. local altarOutputChestDir = "east"
  9. -- Whether or not the script will wait for the altar to have enough LP in it to do the craft
  10. -- Suggested that this is 'false' if you run a well of suffering, or know that you will have enough LP for any given craft
  11. -- Not yet implemented :(/>/>
  12. local checkAltarLPLevelsFirst = false
  13.  
  14. local recipes = {
  15. -- "Vanilla" Blood Magic (Stone -> Slate)
  16. -- {source="Minecraft:blockStone", final="AWWayofTime:blankSlate", lp=1000},
  17.  
  18. -- FTB Infinity Evolved (Expert) Blood Magic (Arcane Stone Block -> Slate)
  19. {source="Thaumcraft:blockCosmeticSolid:6", final="AWWayofTime:blankSlate", lp=1000},
  20.  
  21.  
  22. {source="AWWayofTime:blankSlate", final="AWWayofTime:reinforcedSlate", lp=2000},
  23. {source="AWWayofTime:reinforcedSlate", final="AWWayofTime:imbuedSlate", lp=5000},
  24. {source="AWWayofTime:imbuedSlate", final="AWWayofTime:demonicSlate", lp=15000},
  25. {source="AWWayofTime:demonicSlate", final="AWWayofTime:bloodMagicBaseItems:27", lp=30000},
  26. -- Add other recipes here if you want.
  27. }
  28.  
  29. local altar = peripheral.wrap(altarPeripheralName)
  30. local chest = peripheral.wrap(altarBufferChestName)
  31.  
  32.  
  33. function getAltarItem()
  34. local stack = altar.getItem(1)
  35. if not stack then return nil end
  36. return stack.getMetadata().name
  37. end
  38.  
  39. function altarHasOrb()
  40. local item = getAltarItem()
  41. if item ~= nil and string.find(item, "blood_orb") then
  42. return true
  43. else
  44. return false
  45. end
  46. end
  47.  
  48. function chestHasOrb()
  49. return getChestOrbSlot() ~= 0
  50. end
  51.  
  52. function getChestOrbSlot()
  53. for i=1, chest.size() do
  54. if chest.getItem(i) then
  55. if chest.getItem(i) ~= nil and string.find(chest.getItem(i).getMetadata().name, "blood_orb") then
  56. return
  57. end
  58. end
  59. end
  60. return 0
  61. end
  62.  
  63. function putOrbInAltar()
  64. -- Only check if there is *any* item there. We may be crafting something
  65. -- if the orb is there already, there's no point in running this yet anyway.
  66. if getAltarItem() == nil then
  67. if not chestHasOrb() then
  68. error("The buffer chest does not have an orb in it, and we expect one for re-charging the LP network. Did you remove it?")
  69. end
  70. print("Moving Blood Orb back into the altar to charge LP")
  71. altar.pullItemss(altarBufferChestDir, getChestOrbSlot(), 1)
  72. sleep(0.5)
  73. end
  74. end
  75.  
  76. function removeOrbFromAltar()
  77. if altarHasOrb() then
  78. altar.pushItem(altarBufferChestDir, 1)
  79. sleep(0.5)
  80. end
  81. end
  82.  
  83. function findCraftingRecipe(stack)
  84. local itemId = getItemId(stack)
  85. if itemId then
  86. for i=1, #recipes do
  87. if recipes[i].source == itemId then
  88. if recipes[i].lp <= altar.getTanks()[1].amount then
  89. return recipes[i]
  90. end
  91. end
  92. end
  93. end
  94. return nil
  95. end
  96.  
  97. function getItemId(stack)
  98. if stack then
  99. if stack.dmg ~= nil and stack.dmg ~= 0 then
  100. return stack.id .. ":" .. stack.dmg
  101. else
  102. return stack.id
  103. end
  104. end
  105. return nil
  106. end
  107.  
  108. function craftSlate()
  109. for i=1, chest.size() do
  110. -- Figure out if we have anything to craft
  111. local stack = chest.getItem(i)
  112. local recipe = findCraftingRecipe(stack)
  113. if stack ~= nil then
  114. if recipe ~= nil then
  115. removeOrbFromAltar()
  116. print("Transmuting " .. stack.display_name)
  117. altar.pullItems(altarBufferChestDir, i, 1)
  118. --sleep(0.5)
  119. while getItemId(altar.getStackInSlot(1)) ~= recipe.final do
  120. sleep(0.1)
  121. end
  122. --sleep(0.5)
  123. altar.pushItem(altarOutputChestDir, 1)
  124. --sleep(0.5)
  125. return true
  126. end
  127. end
  128. end
  129. return false
  130. end
  131.  
  132.  
  133. while true do
  134. if not craftSlate() then
  135. putOrbInAltar()
  136. sleep(1)
  137. end
  138. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement