Skip to content

Instantly share code, notes, and snippets.

@puggan
Last active October 16, 2024 21:13
Show Gist options
  • Save puggan/e3d3690af32952a8899931c4e91bea39 to your computer and use it in GitHub Desktop.
Save puggan/e3d3690af32952a8899931c4e91bea39 to your computer and use it in GitHub Desktop.
if not peripheral.isPresent("top") then
print("p-TOP is missing")
return
end
print("p-TOP is " .. peripheral.getType("top"))
if not peripheral.isPresent("bottom") then
print("p-BOTTOM is missing")
return
end
print("p-BOTTOM is " .. peripheral.getType("bottom"))
local col = peripheral.wrap("top")
local bridge = peripheral.wrap("bottom")
while true do
term.clear()
term.setCursorPos(1,1)
-- https://docs.advanced-peripherals.de/peripherals/colony_integrator/#getrequests
requests = col.getRequests()
if requests[1] == nil then
print("No current requests")
end
for key,value in pairs(requests) do
if value.items[1] == nil then
sleep(5)
goto continue
end
for itemIndex,requestedItem in pairs(value.items) do
local itemId = requestedItem.name
local meItemInfos = bridge.getItem({name=itemId})
if not meItemInfos == nil and not meItemInfos[0] == nil then
print(itemId, meItemInfos[0].amount, " / ", value.count)
elseif bridge.isItemCrafting({name=itemId}) then
print(itemId, "+ / ", value.count)
break
elseif not bridge.isItemCraftable({name=itemId}) then
print(itemId, "- / ", value.count)
elseif not bridge.craftItem({name=itemId, count=value.count}) then
print(itemId, "C- / ", value.count)
else
print(itemId, "C+ / ", value.count)
sleep(1)
if bridge.isItemCrafting({name=itemId}) then
break
end
end
end
::continue::
end
sleep(10)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment