CG callbacks and timers

John Perkins

NewTek Staff
I'm having fun this weekend ;)

Here is a small script to create a clock that can be overlayed live.

Code:
//Autoclock.ToasterScript

Clock=CreateControl(255 7 9 "SkinControl_SubControl_Layers")

Clock:{
	AddCallback("Timer", code(
		SetText( AutoClock, GetLocalTime_Time() )
		Update()
		)
	)
}

AddMenuItem("%Auto Clock", 	code( 0 ) )

AddMenuItem("Start Clock", code(
		Clock: {
			StopTimer()		
			StartTimer( 1000 )
		}
	)
)

AddMenuItem("Stop Clock", code(
		Clock:StopTimer()		
	)
)

Name this AutoClock.ToasterScript and place it in both:
C:\VT4\Skins\CG\Large\Main\User Scripts
C:\VT4\Skins\CG\Mini\MainScreen\User Scripts

Then open CG Designer and type in a line of text in whatever style you choose. Go to the layout tab and label that line of text AutoClock.

Menu Items are added that start and stop the clock.

I tried to choose colors for my control that weren't already in use, but I can't guarantee anything. If you do something similar, be careful not to reuse a mask color or else the functionality of what was using that mask color will stop functioning. In my case I killed the File menu on the first try.
 
Last edited:
John

I just got asked today about the possibility of a Clock DSK in VT4.6 Is this going to do it for us?

Give me a call when you can on my mobile so we can get together on this.
 
could this be used as a countdown? We use a 15 minute countdown before each service that we created in AE and run it in the lower righthand corner of the screen over our commercials and announcements.

Just checking. Thanks, John.
 
Here is the 15 minutes count down. The usage is sililar to AutoClock.

Code:
// Count Down 15 minutes, by Chen Pan, AnimLab
//

Secs2Time(x)={
	minute=int(floor(x/60))
	second=int(x-minute*60)
	if(second==60){second=0; minute=minute+1}
	if(minute<10) txt="0"+string(minute)+":"
	else txt=string(minute)+":"
	if(second<10) txt=txt+"0"+string(second)
	else txt=txt+string(second)
	return txt
}

Target=0
CntDown=CreateControl(231 232 234 "SkinControl_SubControl_Layers")

CntDown:{AddCallback("Timer", 
			code(
				sec=Target-int(floor(GetTime()/1000))
				if(sec<=0) txt="00:00"
				else txt=Secs2Time(sec)
				SetText(CountDown, txt)
				Update()
			    )
		    )
	}

AddMenuItem("%CountDown 15 minutes", code(0))
AddMenuItem(" Start CountDown", code( CntDown:{
					Target=int(floor(GetTime()/1000))+ 60 * 15 // 15minx60
					StopTimer() 
					StartTimer(1000) 
					} 
				    )
	   )
AddMenuItem(" Stop CountDown", code( CntDown:StopTimer() ) )
 
Count Up

Here you go, the count-up counter.

Remember, when using Timer callback, you need to stop timer after start timer. Or it might stop working or... crash.


Code:
// Count up by Chen Pan, AnimLab
// Please change UpAmout for your time length
//
UpAmount=60*1+15 // min, sec

Secs2Time(x)={
	minute=int(floor(x/60))
	second=int(x-minute*60)
	if(second==60){second=0; minute=minute+1}
	if(minute<10) txt="0"+string(minute)+":"
	else txt=string(minute)+":"
	if(second<10) txt=txt+"0"+string(second)
	else txt=txt+string(second)
	return txt
}

UpStart=0
UpTarget=0

CntUp=CreateControl(231 232 235 "SkinControl_SubControl_Layers")
CntUp:{AddCallback("Timer", 
			code(
				sec=int(floor(GetTime()/1000))-UpStart
				if(sec>=UpAmount)	txt=Secs2Time(UpAmount)
				else txt=Secs2Time(sec)
				SetText("CountUp", txt)
				Update()
			    )
		    )
	}

AddMenuItem("%CountUp", code(0))
AddMenuItem("  start", code( CntUp:{
					StopTimer() 
					UpStart =int(floor(GetTime()/1000))
					UpTarget=UpStart + UpAmount 
					StartTimer(1000) 
					} 
				    )
	   )
AddMenuItem("  stop", code( CntUp:StopTimer() ) )
 
Hello everyone!

I am a newbie to TS and have not played around with it yet. I want to try out the 15min countdown clock that animlab made but i have no clue how to set up skin for the script. Can anyone give a guide on how? I have made the TS script to show up on "right click" as "Start countdown" "stop Countdown" in CG designer meny.

What is the next step? Do i make skins for this and how?
Where do the "countdown" actually show up?

Thanks
Chribba
 
Copy the code into Notepad.
You can modify the value after variable 'UpAmount', it is count as seconds.
15 minute = 15*60 = 900 seconds.
Save it as C:\VT4\Skins\CG\Large\Main\User Scripts\Counter.ToasterScript (if your VT installation folder is C:\VT4).


Then....
1. Launch VT
2. Launch CG
3. type any text ingo a page
4. goto Layout tab, double click at the Text item and enter the item name as "CountUp"
5. RMB in the CG page, select Counter Up/start.
6. After counter reach it's end, RMB select Counter Up/stop.


That's it.
 
Similiar procedure applied to count down.

The line..
Target=int(floor(GetTime()/1000))+ 60 * 15 // 15minx60
calculate 15 minutes (60*15) for you.
 
animlab said:
Copy the code into Notepad.
You can modify the value after variable 'UpAmount', it is count as seconds.
15 minute = 15*60 = 900 seconds.
Save it as C:\VT4\Skins\CG\Large\Main\User Scripts\Counter.ToasterScript (if your VT installation folder is C:\VT4).


Then....
1. Launch VT
2. Launch CG
3. type any text ingo a page
4. goto Layout tab, double click at the Text item and enter the item name as "CountUp"
5. RMB in the CG page, select Counter Up/start.
6. After counter reach it's end, RMB select Counter Up/stop.


That's it.

Thank you for helping out but must be stupid to not get this right.... This is how i an doing it but something must be wrong..

First i use the script for "Countdown" 15 min. in notepad and save that to C:\VT4\Skins\CG\Large\Main\User Scripts\Counter.ToasterScript
Then i open VT and CG designer, write something in a page and go to layout tab, there i dubbelclick on textline and write countdown. (se pic).

Now should i save this somewhere and where do i see the countdown to be overlayd on a live show?

thanks chribba
 

Attachments

  • CGpage.JPG
    CGpage.JPG
    75.4 KB · Views: 646
chribba said:
Thank you for helping out but must be stupid to not get this right.... This is how i an doing it but something must be wrong..

First i use the script for "Countdown" 15 min. in notepad and save that to C:\VT4\Skins\CG\Large\Main\User Scripts\Counter.ToasterScript
Then i open VT and CG designer, write something in a page and go to layout tab, there i dubbelclick on textline and write countdown. (se pic).

Now should i save this somewhere and where do i see the countdown to be overlayd on a live show?

thanks chribba


Make sure that NOTEPAD didnt add a .txt extentsion to the script file
if your not sure how to check this, then here's a simple proceedure

if your windows explorer is not showing extentions, then go to
TOOLS/FOLDER OPTIONS
VIEW TAB and make sure that "Hide Extentiion" is unchecked
 
ssdcinc said:
Make sure that NOTEPAD didnt add a .txt extentsion to the script file
if your not sure how to check this, then here's a simple proceedure

if your windows explorer is not showing extentions, then go to
TOOLS/FOLDER OPTIONS
VIEW TAB and make sure that "Hide Extentiion" is unchecked


Nope that´s not it!
Can someone tell me what is going to happen when i start countdown? Is there a window popup or where is the countdown? How do you sent it to program out?

thanks
chribba
 
John:
I am not sure that it will work on VT3 or not. But I guess it should work since it did not use any functions new to VT4.

Chribba:
Did you name your Text as 'CountDown' ? It is case sensetive.

When you start count down, you wil see the countdown timer show on the CG work area (at CountDown Text position, and it will replace your original text) every second.

To overlay it to program out
1. In CG Designer, check View/[Output]Output to Switch.
2. In Switcher, select CGDesigner as DSK source, turn DSK on.
 
animlab said:
John:
I am not sure that it will work on VT3 or not. But I guess it should work since it did not use any functions new to VT4.

Chribba:
Did you name your Text as 'CountDown' ? It is case sensetive.

When you start count down, you wil see the countdown timer show on the CG work area (at CountDown Text position, and it will replace your original text) every second.

To overlay it to program out
1. In CG Designer, check View/[Output]Output to Switch.
2. In Switcher, select CGDesigner as DSK source, turn DSK on.



Thanks animlab! The case sensitive was the problem..Now it´s working... I have to read up on the docs for toasterscript so i can help you some day!

thanks again
chribba
 
Hi;

First of all, thanks John and everybody else for these scripts.
I was looking for a way to have a real time clock lonkg time ago.

But here is the thingie:

To work with the clock on a live production i have to keep the CG designer opened all the time and it's big window leave me less space on my monitor then i need (to open DDR's, mixer, etc).

Is there a way i can load the CG file onto a DDR (or CG Player) and have the clock running?

I don't know if you can understand me since my English is not that good :) but, hope you can help me.

Thanks
 
eBrito said:
Hi;

First of all, thanks John and everybody else for these scripts.
I was looking for a way to have a real time clock lonkg time ago.

But here is the thingie:

To work with the clock on a live production i have to keep the CG designer opened all the time and it's big window leave me less space on my monitor then i need (to open DDR's, mixer, etc).

Is there a way i can load the CG file onto a DDR (or CG Player) and have the clock running?

I don't know if you can understand me since my English is not that good :) but, hope you can help me.

Thanks


Just save the clock and copy the script into C:\VT4\Skins\CG\Mini\MainScreen\User Scripts

Then you can open the clock in cg player and you have the countdown there...

chribba
 
Back
Top