Compare commits

...

2 Commits

Author SHA1 Message Date
MayaTheShy
efa79e56cb Add barrel sorting functionality with optional barrel name override 2026-03-16 00:25:13 -04:00
MayaTheShy
d9bb529c21 Add client barrel auto-sort functionality to inventoryClient 2026-03-16 00:25:09 -04:00
2 changed files with 18 additions and 3 deletions

View File

@@ -1384,7 +1384,17 @@ local function main()
end
end,
-- Task 4: Touch event listener (both monitors)
-- Task 4: Client barrel auto-sort (sends to master)
function()
if CLIENT_BARREL_NAME == "" then return end
print("[OK] Client barrel: " .. CLIENT_BARREL_NAME)
while true do
sendToMaster({ type = "sort_barrel", barrelName = CLIENT_BARREL_NAME })
sleep(2)
end
end,
-- Task 5: Touch event listener (both monitors)
function()
while true do
local event, side, x, y = os.pullEvent("monitor_touch")

View File

@@ -2097,8 +2097,9 @@ end
-- Barrel auto-sort
-------------------------------------------------
local function sortBarrel()
local barrel = peripheral.wrap(BARREL_NAME)
local function sortBarrel(barrelOverride)
local barrelTarget = (barrelOverride and barrelOverride ~= "") and barrelOverride or BARREL_NAME
local barrel = peripheral.wrap(barrelTarget)
if not barrel then return end
local contents = barrel.list()
@@ -3181,6 +3182,10 @@ local function main()
saveDisabledRecipes()
smelterNeedsRedraw = true
pcall(broadcastState)
elseif message.type == "sort_barrel" and message.barrelName then
print("[NET] Sort barrel: " .. message.barrelName)
pcall(sortBarrel, message.barrelName)
pcall(broadcastState)
elseif message.type == "craft" and message.recipeIdx then
print(string.format("[NET] Craft request: recipe #%d", message.recipeIdx))
local ok, err = craftItem(message.recipeIdx)