VT | VT-Script Basics
Concept: Initial steps in VT-Script Programming
Module: Text editor
Assets: None
Time: 20 minutes
One of the powerful features under the hood of VT[3] is a complete scripting language, and the ability to link commands to the skins, which are images on the interface itself. Our intrepid video producer and programmer “Aussie” Holten takes us through some initial ‘Hello World’ steps to whet our appetite for customization of this Integrated Production Suite.
First, let’s add a new context menu item to VT-Scope. On your windows desktop, open an explorer window and navigate into VT’s Skins directory. Here you will see folders for most every module. For this example, open the VT-Scope folder located at VideoToaster2\Skins\ToasterScope\
Inside are folders for Skin Groups with Default being the norm. There is also a User Scripts, User Skins and Common Support folder. While each skin has its own script when launching, Common Support is where we keep VT-Scripts that are available to all skins in that module. You could look in there for examples of our scripts, however it is best not to change anything in there since we may overwrite it in the future.
Instead, open the User Scripts folder. The nice thing about the User Scripts folder, which can be found within any module’s setup, is that any script added here will automatically be added to every skin when it starts. Inside this empty folder, use your right mouse button to bring up the windows context menu, and select “New TextFile” (or use NotePad or any word processor that lets you save .txt files. In your text editor write…
// My first ToasterScript
AddMenuItem("%My Scripts", code( 0 ) )
AddMenuItem("Hello script", code( Req_OK(“Hello World”)))
Looking over the above code, anything on a line after “//” is just a comment, so you can add notes, copyright info etc. It’s also a great way to turn off a line of code temporarily.
Uppercase and lowercase are unique, so you must use the right capital letters (except inside the quotes). The “%” sign in the first menu item, indicates that this is a heading and is not to be indented. The pairs of parentheses and quotes must match, so, every opening paren must have its closing companion on the other end. If they do not match you will get a VT-Script error and the script will stop. Req_OK opens up a requester with an OK button.
That’s it. Now, save it with a name like “First Script.ToasterScript” but keep the file open. Note that some text editors will keep changing the ending to “.txt”, so you may have to rename the ending afterwards to “.ToasterScript”. Windows may tell you that you are crazy, but we know better.
Run VT, and bring up VT-Scope and use your right mouse button to trigger the context menu. Select your script and congratulate yourself… you’ve just plugged in!
Your first Keyboard Shortcut
Let’s try a hotkey. Jump back to your text file and add to the end of the file…
// This switches source between Program & Preview
CreateShortCut ("Alt s", code(
if ( IsPreview() ) ProgramOut()
else Preview()
), "OrderedFocus", 100)
This could all have been written in one line, but it’s tidier this way. Save again, jump back to VT and relaunch the VT-Scope, either by closing and reopening, or by switching its skin. Click on the Tscope and press your hotkey. If you have any problem, look for matching pairs of quotes, parentheses and use of Uppercase. The best way to work with VT-Script, is to write a few lines and then test it. If it fails, then the problem is usually in those last few lines.
Isn’t that easy?
Simply dropping any script named “Something.ToasterScript” into a “User Scripts” folder will automatically plug it into every skin of that module.
In my next tutorial, we’ll examine the possibilities that await you in customizing the numerous skins within this Studio-in-a-box.
If you have a tutorial you’d like to submit, or a technique you’d like to see posted as a tutorial, e-mail us at vt2tutorials@newtek.com and we will get it posted! Thanks for stopping by, and be sure to check back often, as the Tutorials page continues to grow. |