Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- BM Altar Automation by Apoc
- -- v1.0 - 2/20/2016
- -- Initial Release
- local altarPeripheralName = "bloodmagic:altar_0"
- local altarBufferChestDir = "west"
- local altarBufferChestName = "minecraft:chest_0"
- local altarOutputChestDir = "east"
- -- Whether or not the script will wait for the altar to have enough LP in it to do the craft
- -- Suggested that this is 'false' if you run a well of suffering, or know that you will have enough LP for any given craft
- -- Not yet implemented :(/>/>
- local checkAltarLPLevelsFirst = false
- local recipes = {
- -- "Vanilla" Blood Magic (Stone -> Slate)
- -- {source="Minecraft:blockStone", final="AWWayofTime:blankSlate", lp=1000},
- -- FTB Infinity Evolved (Expert) Blood Magic (Arcane Stone Block -> Slate)
- {source="Thaumcraft:blockCosmeticSolid:6", final="AWWayofTime:blankSlate", lp=1000},
- {source="AWWayofTime:blankSlate", final="AWWayofTime:reinforcedSlate", lp=2000},
- {source="AWWayofTime:reinforcedSlate", final="AWWayofTime:imbuedSlate", lp=5000},
- {source="AWWayofTime:imbuedSlate", final="AWWayofTime:demonicSlate", lp=15000},
- {source="AWWayofTime:demonicSlate", final="AWWayofTime:bloodMagicBaseItems:27", lp=30000},
- -- Add other recipes here if you want.
- }
- local altar = peripheral.wrap(altarPeripheralName)
- local chest = peripheral.wrap(altarBufferChestName)
- function getAltarItem()
- local stack = altar.getItem(1)
- if not stack then return nil end
- return stack.getMetadata().name
- end
- function altarHasOrb()
- local item = getAltarItem()
- if item ~= nil and string.find(item, "blood_orb") then
- return true
- else
- return false
- end
- end
- function chestHasOrb()
- return getChestOrbSlot() ~= 0
- end
- function getChestOrbSlot()
- for i=1, chest.size() do
- if chest.getItem(i) then
- if chest.getItem(i) ~= nil and string.find(chest.getItem(i).getMetadata().name, "blood_orb") then
- return
- end
- end
- end
- return 0
- end
- function putOrbInAltar()
- -- Only check if there is *any* item there. We may be crafting something
- -- if the orb is there already, there's no point in running this yet anyway.
- if getAltarItem() == nil then
- if not chestHasOrb() then
- 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?")
- end
- print("Moving Blood Orb back into the altar to charge LP")
- altar.pullItemss(altarBufferChestDir, getChestOrbSlot(), 1)
- sleep(0.5)
- end
- end
- function removeOrbFromAltar()
- if altarHasOrb() then
- altar.pushItem(altarBufferChestDir, 1)
- sleep(0.5)
- end
- end
- function findCraftingRecipe(stack)
- local itemId = getItemId(stack)
- if itemId then
- for i=1, #recipes do
- if recipes[i].source == itemId then
- if recipes[i].lp <= altar.getTanks()[1].amount then
- return recipes[i]
- end
- end
- end
- end
- return nil
- end
- function getItemId(stack)
- if stack then
- if stack.dmg ~= nil and stack.dmg ~= 0 then
- return stack.id .. ":" .. stack.dmg
- else
- return stack.id
- end
- end
- return nil
- end
- function craftSlate()
- for i=1, chest.size() do
- -- Figure out if we have anything to craft
- local stack = chest.getItem(i)
- local recipe = findCraftingRecipe(stack)
- if stack ~= nil then
- if recipe ~= nil then
- removeOrbFromAltar()
- print("Transmuting " .. stack.display_name)
- altar.pullItems(altarBufferChestDir, i, 1)
- --sleep(0.5)
- while getItemId(altar.getStackInSlot(1)) ~= recipe.final do
- sleep(0.1)
- end
- --sleep(0.5)
- altar.pushItem(altarOutputChestDir, 1)
- --sleep(0.5)
- return true
- end
- end
- end
- return false
- end
- while true do
- if not craftSlate() then
- putOrbInAltar()
- sleep(1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement