Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------------------------------------------------------------------------------------
- -- BM Altar by ame824
- -- created Jan 2021
- -- last update Oct 2022
- ------------------------------------------------------------------------------------------------------------------------------
- --config
- ------------------------------------------------------------------------------------------------------------------------------
- local altarBufferChestDir = "west"
- local altarBufferChestName = "gold"
- 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
- local checkAltarLPLevelsFirst = true
- ------------------------------------------------------------------------------------------------------------------------------
- --reciepes
- ------------------------------------------------------------------------------------------------------------------------------
- local recipes = {
- -- "Vanilla" Blood Magic (Stone -> Slate)
- {source="minecraft:stone", 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.
- }
- ------------------------------------------------------------------------------------------------------------------------------
- --DON'T CHANGE ANYTHING UNDER THIS
- ------------------------------------------------------------------------------------------------------------------------------
- local altar = peripheral.find("tealtar")
- local chest = peripheral.find(altarBufferChestName)
- function getAltarItem()
- local stack = altar.getStackInSlot(1)
- if not stack then return nil end
- return stack.name
- end
- function getAltarLevel()
- local altarInfo = altar.getInfo()
- local level = altarInfo.contents.amount
- return level
- end
- function altarHasOrb()
- local item = getAltarItem()
- if item ~= nil and string.find(item, "Orb") then
- return true
- else
- return false
- end
- end
- function chestHasOrb()
- return getChestOrbSlot() ~= 0
- end
- function getChestOrbSlot()
- for i=1, chest.getInventorySize() do
- if chest.getStackInSlot(i) then
- if string.find(chest.getStackInSlot(i).name, "Orb") then
- return i
- 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.pullItem(altarBufferChestDir, getChestOrbSlot(), 1)
- sleep(0.5)
- end
- end
- function removeOrbFromAltar()
- if altarHasOrb() then
- altar.pushItem(altarBufferChestDir, 1)
- sleep(0.5)
- end
- 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 findCraftingRecipe(stack)
- local itemId = getItemId(stack)
- if itemId then
- for i=1, #recipes do
- local source = recipes[i].source
- if source == itemId then
- return recipes[i]
- end
- end
- end
- return nil
- end
- function craftSlate()
- for i=1, chest.getInventorySize() do
- -- Figure out if we have anything to craft
- local stack = chest.getStackInSlot(i)
- local recipe = findCraftingRecipe(stack)
- local altarLP = getAltarLevel()
- if stack ~= nil then
- if recipe ~= nil then
- local recipeLP = recipe.lp
- if not checkAltarLPLevelsFirst then
- removeOrbFromAltar()
- print("Transmuting " .. stack.display_name)
- altar.pullItem(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)
- else
- if altarLP >= recipeLP then
- removeOrbFromAltar()
- print("Transmuting " .. stack.display_name)
- altar.pullItem(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)
- else
- if not getChestOrbSlot() then removeOrbFromAltar() end
- print("to Less LP for Recipe...")
- end
- end
- 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