If anyone else is interested, here's the combined version of my script and Jamian's.
This does what I was trying to accomplish. Here are the possible settings.
1. Play a sound at once and only once on a screen. Leave all setting but the top at zero.
2. Play a sound after a delay only once on a screen. Set sound on the first line and how long to wait on the second. Leave everything else at zero.
3. Play a sound either at once or after a delay every time you enter a screen. Set D3 to anything other than zero, use D1 to set the sound and D2 for any delay.
4. Play a sound repeatedly while on a screen, but only on that screen. Have that sound play at once or after a delay. Set D5 to anything other than zero. Be sure to set frequency and max to anything above zero.
5. Play a sound repeatedly while on a screen, every time you visit that screen. Set SFXRepeats and SFXLoops to anything other than zero. Make frequency and max positive numbers.
All times used for how long to wait and how often to repeat are measured in frames.
I'm only guessing that frequency and max should be set to the same thing every time, but it seems to make sense. I've been trying to develop this on my own without asking for a script that does this, but since the topic existed I thought I'd try and see if I could learn anything by trying to combine what I'd invented and what was posted here. This only puts me one step closer to my goal of learning to script far more complex things. Please note that with current setup you can only have one of these on a screen, but then again; who'd need more than one? I'm planning to use it to add timed sounds to future cutscenes, myself.
Edited by ywkls, 06 January 2015 - 01:51 PM.