how to make a script turn on and off with computer

I have a script that I want to turn on when the computer comes on. I want it to loop until the computer turns off. How can I do this. I am sure I can tell the computer to lanch no startup, but what kind of loop can I do to keep it going until the computer turns off?

repeat until computer turns off
“SCRIPT”
end repeat

bones:

Try this:

repeat
--SCRIPT
end repeat

Once you have your script working the way you want, put it inside the repeat loop, save it as an application, and then go to your Accounts section in System Preferences. From there, you can select applications to launch whenever the computer comes alive.