Skip to content

Instantly share code, notes, and snippets.

@rodjek
Last active March 7, 2025 05:05
Show Gist options
  • Save rodjek/80eae06e995f5a3c8b6082b19cc8bcd8 to your computer and use it in GitHub Desktop.
Save rodjek/80eae06e995f5a3c8b6082b19cc8bcd8 to your computer and use it in GitHub Desktop.
sb3
local altarName = "bloodmagic:altar_0"
local inputName = "minecraft:barrel_0"
local outputName = "minecraft:barrel_1"
local altar = peripheral.wrap(altarName)
local input = peripheral.wrap(inputName)
local output = peripheral.wrap(outputName)
function getAltarItem()
local stack = altar.getItemDetail(1)
if not stack then return nil end
return stack.name
end
function altarHasOrb()
local item = getAltarItem()
if item ~= nil and string.find(item, "bloodorb") then
return true
else
return false
end
end
function chestHasOrb()
return getChestOrbSlot() ~= 0
end
function getChestOrbSlot()
for i=1, output.size() do
if chest.getItemDetail(i) then
if string.find(chest.getItemDetail(i).name, "bloodorb") 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 output 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.pullItems(outputName, getChestOrbSlot(), 1)
sleep(0.5)
end
end
function removeOrbFromAltar()
if altarHasOrb() then
altar.pushItems(outputName, 1, 1)
sleep(0.5)
end
end
function rechargeLP()
if not altarHasOrb() then
putOrbInAltar()
end
sleep(5)
removeOrbFromAltar()
end
function refillAltar()
while altar.tanks()[1].amount < 53000 do
sleep(1)
end
end
function addStoneToAltar()
altar.pushItems(inputName, 1, 1)
sleep(0.5)
end
function altarCrafting()
local item = getAltarItem()
if item == nil then
return false
end
return item ~= "bloodmagic:etherealslate"
end
function pushSlateToOutput()
altar.pushItems(outputName, 1)
sleep(0.5)
end
function craftSlate()
removeOrbFromAltar()
refillAltar()
addStoneToAltar()
while altarCrafting() do
sleep(1)
end
pushSlateToOutput()
end
while true do
craftSlate()
rechargeLP()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment