turtle.compareTo() can be used to identify your items, but you need to pre-populate the turtle's inventory with samples of those items. CC can't identify things by ID numbers (by design), though some addons allow this.
os.startTimer and
os.pullEvent can be used to start counting your 48 hour period and catch it when it ends. Because the turtle/computer normally cannot catch events while doing other things (eg checking for new items in the chest), you need to have it
multitask.
Although you wouldn't know it from the wiki page, use of parallel functions allow you to effectively duplicate the event queue, letting two functions pull from it at once without blocking those events from the other function.
This is handy when you realise that certain functions pull events from the queue, including unrelated events (eg your timer events) - meaning you might not be able to pull them yourself, so you never know when your timers have expired. None are documented as doing so, so have fun figuring that out on your own, but as a starting point I can tell you most turtle functions do this. Use of the parallel API solves all this.
More importantly, in your case, it allows you to have one function sit and do nothing (wait for timer events to fire) while another does actual work (starts new timers based on what the chest is doing).
local timerlist = {} -- We'll use one index per type of item in the turtle's inventory.
local function main()
turtle.select(1)
while true do
-- Pull stuff from the chest into the first slot of the turtle.
for i=2,16 do if turtle.compareTo(i) then -- Try to match the chest item with something the turtle's carrying.
timerlist[i] = os.startTimer(172800) -- Start a timer to end two days from now.
-- Enable your redstone signal for the item matching the type in turtle slot i.
break
end end
-- Send that item away somewhere.
end
end
local function catchTimers()
local event,timerID = "",0
while true do
event, timerID = os.pullEvent("timer")
for i=1,table.getn(timerlist) do if timerlist[i] == timerID then
timerlist[i] = 0
-- The timer for the item type matching whatever's in turtle slot i
-- just expired, so toggle your redstone signal off or whatever.
break
end end
end
end
parallel.waitForAny(main, catchTimers) -- Run the two functions at once.