Skip to content

Instantly share code, notes, and snippets.

@MacChuck
Last active March 21, 2025 04:42
Show Gist options
  • Save MacChuck/88bd3a4e60313b3e219797eeb56baab5 to your computer and use it in GitHub Desktop.
Save MacChuck/88bd3a4e60313b3e219797eeb56baab5 to your computer and use it in GitHub Desktop.
mon = peripheral.find("monitor")
bridge = peripheral.find("meBridge")
os.startTimer(1)
mon.setTextScale(.5)
mon.clear()
monW,monH = mon.getSize()
displayItems = {"netherite_ingot","allthemodium:allthemodium_ingot","allthemodium:vibranium_ingot","allthemodium:unobtainium_ingot"}
stockItems = {}
function drawStock()
line = 1
for _, item in pairs(displayItems) do
itemDetail = bridge.getItem({name=item})
cleanName = itemDetail.displayName:sub(5,-2) -- Trim leading spaces and [] from the display name.
if cleanName == "Air" then -- If the item is valid but missing, the peripheral returns Air
cleanName = item
end
mon.setCursorPos(1,line)
mon.write(cleanName)
mon.setCursorPos(monW/2,line)
mon.write(tostring(itemDetail.count))
line = line + 1
end
end
function drawCraftables()
line = #displayItems+1
for item,count in pairs(stockItems) do
itemDetail = bridge.getItem({name=item})
cleanName = itemDetail.displayName:sub(5,-2) -- Trim leading spaces and [] from the display name.
if cleanName == "Air" then -- If the item is valid but missing, the peripheral returns Air
cleanName = item
end
if bridge.isItemCraftable({name=item}) then
mon.setCursorPos(1,line)
mon.write(cleanName)
mon.setCursorPos(monW/2,line)
mon.write(tostring(itemDetail.count).." / "..count)
if bridge.isItemCrafting({name=item}) then
mon.setCursorPos(monW*.75,line)
mon.setTextColor(colors.green)
mon.write("Crafting")
mon.setTextColor(colors.white)
end
else
mon.setCursorPos(1,line)
mon.write(cleanName)
mon.setCursorPos(monW/2,line)
mon.setTextColor(colors.red)
mon.write("No Recipe")
mon.setTextColor(colors.white)
end
line = line + 1
end
end
function craftItem(itemName,qty)
if bridge.isItemCrafting({name=itemName}) then --crafting job already going, no need to queue another
return
else
bridge.craftItem({name=itemName,count=qty})
end
end
function checkStock()
for item,count in pairs(stockItems) do
itemDetail = bridge.getItem({name=item})
if itemDetail.count < count/3 then --craft more if at a 3rd of the stock threshold
craftItem(item,(count-itemDetail.count))
end
end
end
while true do
local evt,sid,msg,proto = os.pullEvent()
if evt == "timer" then
mon.clear()
drawStock()
--checkStock()
--drawCraftables()
os.startTimer(60)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment