Game Development Community

Torque2D TextMate Bundle

by Scott Lahteine · in Torque Game Builder · 11/25/2006 (8:27 am) · 6 replies

I recently discovered TextMate, a new super-extensible editor for Mac OS X. It has a feature called the "Bundle Editor" that enterprising geeks can use to extend the program in some pretty amazing ways. The program comes with a few dozen bundles supporting the most popular programming and scripting languages, and you can grab a hundred more through their public SVN server. The bundles themselves are completely open, so you can view, edit, and learn from them.

Considering the hundreds of obscure languages that are supported, I was quite surprised to discover that up to now no one has created a TorqueScript bundle. So I started poking through the Javascript and PHP bundles, copying segments and adapting the code to Torque 2D. I'm happy to announce that today the Torque2D bundle is ready.

Click here to download Torque2D For TextMate

Feel free to extend and improve it. It's basically Alpha or Beta quality at this point, but the important stuff is in place. Here are the notes from the README file:

Enhancements Provided By This Bundle...

Language Syntax

This bundle enables TextMate to identify functions, methods, variables, constants, strings, comments, operators, strings, Torque 2D's classes and class methods, all documented Console functions, and all control keywords.

Templates
This bundle adds a Torque2D sub-menu to the File > New From Template menu, enabling you to create new CS and GUI files with timestamp and author information.

Snippets
Use the Snippets menu (at the bottom of each editor window) to insert Torque2D snippets. You can also use Tab Triggers to insert snippets. After inserting a snippet you can use the TAB key to edit each field in turn. The following Snippets are provided in this release, with more to come...

[b]Snippet                         Tab Trigger[/b]
Function                        func
Method                          meth
onCollision                     coll
datablock (Animation)           dba
datablock (CollisionMaterial)   dbc
datablock (ImageMap)            dbi
datablock (SceneObject)         dbo

Drag Actions
Dragging an image or sound file into the editor inserts a populated datablock Snippet. Then use the TAB key to navigate and edit the parameters. Any files you drag and drop this way should already be in your game's "data" folder. A future version of this bundle will copy files to the appropriate location (either data/images or data/audio) prior to code insertion.

Caveats
In identifying functions there is no discernment between the class part and the method-name part. The double-colon is taken as part of the overall name, and this works fine.

Some datablock snippets may seem large. (The SceneObject snippet has 64 distinct fields!) A future release will address this by adding some more specialized snippets having fewer fields.

You may find that quotes, brackets, parentheses, and braces automatically insert pairs when editing. You can change this annoying behavior in TextMate's preferences by disabling the "Auto-pair Characters" option.

Future Plans...
- Snippets for many common callbacks.
- Keyword and method expansion with the escape key.
- Add menu items to control Torque Game Builder at the shell level for things like syntax checking, game execution, log viewing, etc.

#1
11/26/2006 (3:25 pm)
Scott,
This is awesome!
This totally helps me out!
TextMate is great, i'll probably purcahase it before the month's out...
and your bundle is great!!

thanks!
Joe
#2
11/27/2006 (1:43 pm)
I just posted an updated version...

This update adds snippets for SimObject, ScriptObject, SimSet and SimGroup.

(Be sure to delete the old "Torque2D" bundle using the Bundle Editor before installing this one.)
#3
11/28/2006 (3:05 am)
Hmmm...if I had seen this 36 hours ago I could have skipped some typing -- I just added a bunch of snippets to the TorqueScript bundle I had started putting together. =:)

But now I've added those snippets to your bundle -- thanks for the gift!

Jay Jennings
#4
11/28/2006 (12:19 pm)
I'm glad you like the bundle, Jay! What code snippets did you add? I'll make sure to include them in the next version of the bundle.
#5
11/29/2006 (1:05 am)
I went through and added even the "little" stuff, like: if, for, else, switch, while, etc. Anything where I might be typing more than a single line.

for ( ${1:startVal} ; ${2:comparison} ; ${3:varOperation}++ )
{
${4:code}
}
#6
12/05/2006 (8:43 pm)
Nice work, Scott. FYI There was a TextMate bundle posted on the TGE forum last year. What I'm desperately seeking is debugger support. I was thinking about hacking it into Smultron when I remembered I should work on the game.