Last active
March 21, 2025 04:42
-
-
Save MacChuck/88bd3a4e60313b3e219797eeb56baab5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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