Game Development Community

Script differences? TGEA/T3D

by M. Jackson · in General Discussion · 02/03/2011 (6:43 am) · 14 replies

With TDN up and plans for it to be updated and regularly maintained, along with the shift in my project from pure art development to mechanics, I feel that the time is right for me to ask a Question that I've been mulling over for quite some time.

The documentation distributed with T3D does cover script, but only in a limited fashion. I am certain that I could blunder my way through the bit of code that I need despite not having a codeing/programming heavy background, but I would rather examine a few more examples. The problem is that TDN does not appear to have a T3D section and most of the examples of TS that I've dug up from elsewhere are for TGE or TGEA.

So, my question is, what is the difference, if any, between TS in TGEA and T3D? I would assume that most of it is exactly the same; why reinvent the wheel, after all. However, I also assume that a new version brings new functions as well as revisions on many remaining functions.

As an aside, does anyone know if LUA can still be included as per (http://www.garagegames.com/community/blogs/view/9665) or (http://www.garagegames.com/community/blogs/view/13300) or has there been a development on the subject of LUA that I simple have not found?

#1
02/03/2011 (7:44 am)
@M. Jackson -
Quote:The documentation distributed with T3D does cover script, but only in a limited fashion

What specifically do you need to know that is not covered in TorqueScript Manual?

That covers all the functions, class methods, member variables, full language syntax and some examples for many different objects. Far more comprehensive than TGEA. The language itself is the same, with the addition of a couple new keywords like foreach. As for Lua, there are no plans at this time to bring it into Torque 3D. We have a lot higher priorities regarding stability and performance we are trying to address.
#2
02/03/2011 (8:17 am)
The TorqueScript Manual is a document written by programmers that are very familiar with the subject that they are writing about. Thus, I say that it does cover every aspect of TS, but is uneasy to approach unless one already has a full working knowledge of C++. One like me, who has more familiarity with higher level languages, can work through it, but only through trial and error.

For example, I have a background heavy in English grammar with a good deal of French. If I were to explain to you how to translate Present Progressive Perfect Tense into French would you have any clue what I was talking about? Unlikely, but you use English every day thus a clinical description of the verb functionality should work...right? Well, yes, if you are a linguist, but otherwise no. We learn language in the same way one learns programming, by modeling.

That document on TS is a complete reference for one who already knows its base language. I am not asking for that to change, but what I am asking for, and you have already answered to a large degree, is for example code. There is plenty of code for TGE and TGEA for my uses, I simply needed to know that it was still applicable.

(BTW "I have been reading" is Present Perfect Progressive Tense)
#3
02/03/2011 (9:05 am)
@M. Jackson -
Quote:If I were to explain to you how to translate Present Progressive Perfect Tense into French would you have any clue what I was talking about?

Rare case, but I could actually figure it out having done that for Spanish and being a past English major...but I get your point =)

I'm not sure I follow about the prior knowledge. I wrote two specific guides geared toward those new to TorqueScript and basic programming: Overview and Syntax. Also, in that manual look for the Player class. Note how it goes into detail for setting up a class. It's not just reference, but an actual guide.

Additionally, some of the most commonly used operations in TorqueScript do get covered in the Official Docs. These are found under Scripting->Simple. I could definitely expand that some, but an example for every single operator is going to be a lengthy process. Overall, I wanted to write the T3D docs as if TGE and TGEA never existed. I did not want to send new users on a scavenger hunt through other other engine docs just to find simple script examples. A very clear example is explaining the basic rules of TorqueScript development.

My main rules: Don't assume they have prior knowledge of TorqueScript, allude to the basics of C++ but don't make it a prerequisite, but do assume they have knowledge of programming concepts.
#4
02/03/2011 (9:53 am)
Quote:
So, my question is, what is the difference, if any, between TS in TGEA and T3D?
No functional difference. Some extra TS sugar in T3D... and a few class or function names mismatch if you're porting from TGE/TGEa (easily handled).
#5
02/03/2011 (9:58 am)
@Michael - Essentially, though I would not down play the number of under the hood changes. While Player may still be the same in TS, there are changes to the class hierarchy that accommodate the new doc system from engineAPI. Other than that, you are looking at the same end result TS functionality.

Now, expanding the scripts is drastically different. If you want to add a global function, you previously created a ConsoleFunction in C++. Now, you would use the DefineEngineFunction macro. There are several changes like that for ConsoleMethod, addField, DECLARE_CALLBACK, and so on. Something worth noting.
#6
02/03/2011 (10:09 am)
True, but the question was about script differences, not C++ ;)
#7
02/03/2011 (11:10 am)
@Michael - Indeed, but sometimes knowing what's under the C++ hood helps someone understand the script flow. This is especially true for expanding the language. Not necessary, but definitely a +
#8
02/03/2011 (3:29 pm)
@Michael Perry: The way I see it is that a person who already knows C++, or a similar language, would only need the TS manual while while one who does not already know C++ must use the same manual to completely dissect various snippets in order to learn how the language wants to work.

In all honesty, I am trying to skip a step. Specifically, I know that the best course of action would be to spend some time learning C++ before tackling TS, but, alas, I have too many hats as it is.

My question regarding LUA was more specific. I have an application that nativity operates in LUA. The output of that application is functional code that I wish to call from TS. I have three options: (1) manually rewrite potentially thousands of lines of code into TS; (2) write an exporter for the application; or (3) integrate LUA into the compiled executable as per the examples that I previously listed.

Obviously, if either of those examples will still work that would be the simplest rout, as I only need to expose a small number of variables from each script to the other. If, however, nothing of the sort can be done, or it is beyond my abilities at this time, then option 2 has my favor.

EDIT: By the way, thank you both. Even if I cannot get resolution on my LUA intrigue you have certainly provided me with what I needed in order to proceed.
#9
02/04/2011 (12:15 pm)
@M. Jackson

I just wanted to let you know that this resource works just fine in Torque 3D. If you need help integrating in T3D let me know.
#10
02/04/2011 (12:50 pm)
Thank you very much. That is the method that I was rather hoping would work. I will experiment with it on my own, but, should I encounter any difficulties, I will certainly accept your offer of assistance. Thank you all again.
#11
02/04/2011 (3:54 pm)
One thing I've noticed in T3D that seems to be new is the use of the -> operator on objects as well as the usual dot. I've also even seen --> on one occasion. Is this just a synonym for the dot, or does it have different functionality?
#12
02/04/2011 (4:38 pm)
@Daniel - That is specifically geared toward the GUI system and accessing parent/child objects via specific way.
#13
02/04/2011 (4:58 pm)
@Daniel

Those are the internal name operators. They reference whatever object that has that internal name that it points to. I think they are mainly used in GUI stuff, but they can be used for any object in Torque.

Basically if you have child objects inside of another object(Ex. GuiTextEditControl inside a GuiWindow) you can create those objects with internal names and only those objects who are in that group can reference those names.

So the syntax is:
Parent(Object id, objectname)-->ChildObjectsInternalNameInsertHere


An example is

new GuiWindowCtrl(Window)
{
    internalname = "MyWindow";

    new GuiTextEditCtrl()
    {

       internalname = "TextControl;
    }
}


function GuiWindowCtrl::getText(%this)
{
   %text = %this-->TextControl.getText();
   return %text;
}

#14
02/04/2011 (7:39 pm)
Also, T3D has a HUGE amount of stuff exposed to console. And most importantly, whatever is exposed is commented, so working with TS in Torque 3D in Torsion is nothing like it used to be in TGEA.

Another neat feature is the addition of "foreach" that iterates through a collection of objects in an object array - thanks to Rene Damm.