As loki mentioned, the block of code you posted has every type of information you need to fill in the outline I posted.
It has the ontext command, setting variables, checking variables, and actual script/to-do code.

I tried and added some clarity to my original posting of the outline. If you are still confused, maybe it will help