Advertisement
Alexr360

Archival Log

Feb 20th, 2024 (edited)
877
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. -- Function to log item changes in a chest
  2. local function logItemChanges()
  3.     local chest = peripheral.find("storagedrawers:controller")
  4.     local itemsBefore = {}
  5.    
  6.     -- Store item counts before waiting
  7.     for _, item in pairs(chest.list()) do
  8.         itemsBefore[item.name] = item.count
  9.     end
  10.  
  11.     -- Wait for 1 minute
  12.     sleep(15)
  13.  
  14.     local itemsAfter = {}
  15.    
  16.     -- Store item counts after waiting
  17.     for _, item in pairs(chest.list()) do
  18.         itemsAfter[item.name] = item.count
  19.     end
  20.  
  21.     -- Compare item counts before and after
  22.     for name, countBefore in pairs(itemsBefore) do
  23.         local countAfter = itemsAfter[name] or 0
  24.         local countChange = countAfter - countBefore
  25.         if countChange ~= 0 then
  26.             print("Item '" .. name .. "' count changed by " .. countChange)
  27.         end
  28.     end
  29. end
  30.  
  31. -- Main loop
  32. while true do
  33.     logItemChanges()
  34. end
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement