See the official sequencer script page for more helpfull information about the sequencer and scripting.