Compare commits

...
Sign in to create a new pull request.

4 commits

Author SHA1 Message Date
Emerson Rosen-Jones
23c8afe8ee fix: keep config static 2025-12-26 23:05:09 -05:00
Emerson Rosen-Jones
ed4f44fc9d fix: remove syntax error 2025-12-26 23:04:33 -05:00
Emerson Rosen-Jones
038b1b739c fix: remove syntax error 2025-12-26 22:04:05 -05:00
Emerson Rosen-Jones
19cdb67281 feat: create stock manager for removing excess stock 2025-12-22 21:50:23 -05:00

44
stock-manager.lua Normal file
View file

@ -0,0 +1,44 @@
-- Program that manages a stock system
-- For now this just means removing "waste" but in the future it could involve
-- - Displaying information to the user
local STOCK_SOURCE = ""
local DISCARD_ADDR = ""
local LARGE_COMPACTING_ADDR = ""
local SMALL_COMPACTING_ADDR = ""
local KEEP_ONLY = {}
KEEP_ONLY["minecraft:quartz"] = {6 * 64, DISCARD_ADDR}
KEEP_ONLY["minecraft:prismarine_shard"] = {2 * 64, DISCARD_ADDR}
local DISCARD_REST = false
local SLEEP_T = 10
function remove_waste(source, discard_rest)
local amounts_to_keep = KEEP_ONLY
local discard = function (item, amt, dest)
peripheral.call(source, "requestFiltered", dest,
{
name = item.name,
_requestCount = amt,
}
)
end
for slot, item in pairs(peripheral.call(source, "stock")) do
if amounts_to_keep[item.name] ~= nil then
local excess = item.count - amounts_to_keep[item.name][1]
if excess > 0 then
discard(item, excess, amounts_to_keep[item.name][2])
end
elseif DISCARD_REST then
discard(item, amt, DISCARD_ADDR)
end
os.sleep(1)
end
end
while true do
remove_waste(STOCK_SOURCE, DISCARD_REST)
os.sleep(SLEEP_T)
end