This script will tell you the current frame, followed by your TIDs, and output them to a txt file. I set it to test.txt because I wasn't sure if it would work sometimes. I also made a script for Yellow version.
file = io.open("test.txt", "w")
io.output(file)
-- prints the frame count while running
while true do
io.write(emu.framecount())
io.write(", ")
tid = memory.read_u16_be(0XD359)
io.write((tid), "\n")
emu.frameadvance()
end
io.close(file)