// In order for this example to work completely, you need to have // TGB, along with the TGB source. In the future, this may not be // necessary. But for this example, it is. // This file needs to be in a TorqueEDIT project... go to // File->New->Project... and select Torque Project from the list. // For the location, you can specify a folder with your TGB source // code in it (or this file), or you can leave it as the default. // If you specify a folder, then you will directly manipulate // the files there. Otherwise, you need to import the project files // into the project, and then you will have to copy the modified files // from the workspace to where TGB is located. I recommend specifying // a project folder. Note that the TGB project must have already been // created from inside TGB. // You also need to go to Window->Preferences->TorquEDIT, and // specify the engine source folder for TGB, and make sure the // "Use TGB" checkbox is marked. // // You can construct a // similar example for TGE or TGEA. The behavior is the same. // Not all of the classes in the completion list are exposed to // scripting... that will be fixed in the future. For now, if you // select a class, and then Torque complains about the class not // existing, then it's a C++-only class. // On with the examples. new t2dSceneGraph(sceneGraph) { field = "ignored"; }; // Try starting to type sce, then pause for half a second // A window showing sceneGraph should pop up. You can use the arrows // to select a suggestion, then press enter to insert it. Or you // can press esc to get rid of the window. function funcTest(%param1, %param2) { // Local variables are only available for completion in the scope // They are used or defined. Only local variables inside a // function are setup for completion (this may change, so local // variables outside functions are ok too, even though that's // bad programming practice). %blah = %param2 + %param1; } // So now, below this comment, // when you start typing %, nothing should show up. // If you make changes to the document, the autocompletion will not // be refreshed until you save. In some cases, you may need to clean // the project for everything to by correct. Just go up to // Project->Clean... and select the projects to clean. This will // fully rebuild the completion structures from the engine source // code (if available and selected) and from your script source code. $global = new t2dStaticSprite(anotherGlobal); // Now $global and anotherGlobal are defined as t2dStaticSprites. // Type "$global." That means type $global followed by a period, dot // tochka, punto, or full stop (depending on where you're from). // All of the member functions and variables related to // t2dStaticSprite pop up for you to choose from. function grandparent::aMethod(%this, %unknownParameter) { // When you start a comment with //# that means a special command follows. // You can comment out the special comment and the parser will ignore it. // That is, you can type ///# or ////# and the parser will treat it as // a normal comment. // The particular special comment below defines the class type of the // specified variable. The first line is like saying: // "The variable %unknownParameter is a t2dParticleEffect" //# %unknownParameter t2dParticleEffect //# $unknownGlobal myparent //# $unknownGlobal.testfield SimGroup // This is necessary because torqueScript is a typeless language. // I extract the class/type whenever possible, but sometimes I // can't get it, or it just misses it or something. So you can // define it explicitly when you need to. // The implementation of the special comment adds the class to a list of parents, // so you can specify several parents. Keep in mind that this // does absolutely NOTHING to do with torque or tgb, it will not // change the way your code works. This is only for code completion // purposes. // So, try it out. Below the comments, start typing // one of the variables defined (like the first 2 letters), // pause for half a second, then select an item from the list. // The bottom example is especially cool... try typing a . at // the end of the defined variable. %this.grandField = "something"; } function myparent::lookForMe(%this, %second) { // t2dVector is NOT actually a console class. // It is something I made up to help with code completion // The only way to use it right now is to use the // special comment //# to define it //# %second t2dVector // Now try typing %second. and see what pops up. // Then select one of the options. Neat huh? %object = new t2dAnimatedSprite() { class = "myparent"; superclass = "grandparent"; }; %this.childField = new ScriptObject(); // Now notice that %object has childField and grandField in its // completion options (grandField is defined above). It also // has aMethod and lookForMe. } // TODO make totally awesome game // TODO1 High priority // TODO2 Normal priority (don't really need the 2) // TODO3 Low priority // Open up the tasks view. Window->Show View->Tasks // Notice the TODO item above. The syntax is // TODO (can be lowercase), // then whatever. The TODO just has to be the first thing in the comment. // If a number 1, 2, or 3 follows immediately after the todo, then // the priority for the task is set.