ts = peripheral.wrap("back") --[[ on the tick where the train was imminent, but was not present. and now is present and imminent: payload sequence ]] function ready() wasimminent = isimminent isimminent = ts.isTrainImminent() waspresent = ispresent ispresent = ts.isTrainPresent() if wasimminent and isimminent and (not waspresent) and ispresent then payload() end end function payload() sleep(0.3) if ts.isTrainPresent() then ts.disassemble() sleep(0.3) ts.assemble() end end repeat ready() sleep(0.05) until false