Difference in TorqueScript between TGB and TGE?
by Joe Sopko · in Torque Game Builder · 11/12/2009 (5:38 pm) · 13 replies
Long story short I just want to know if TorqueScript is EXACTLY the same between the two engines or each has some difference built-in functions and syntax. Also if they aren't does anyone know to what to degree they differ or somewhere I could find out? Thanks.
#2
11/12/2009 (6:42 pm)
Thanks for the quick reply Ronnie, I appreciate it. I was curious because I have The Game Programmer's Guide to Torque and was curious as to whether or not the section including TorqueScript would be any help because it was done with TGE and I'm currently using TGB, but you've answered my question. Take care.
#3
11/13/2009 (4:49 am)
Specifically I believe the last merge from TGE was v1.5 although there *may* be minor differences.
#4
11/13/2009 (8:31 pm)
Do you know in what regards there may be minor differences? More importantly difference in syntax?
#5
I'm pretty sure that syntax does not work in TGE. The equivalent is:
11/13/2009 (9:15 pm)
One that I can think of offhand is that TGB has an object syntax like this:new ObjectType(["nameGoesHere"]) { ... };I'm pretty sure that syntax does not work in TGE. The equivalent is:
new ObjectType() { internalName = "nameGoesHere"; };
#6
Also, the naming convention works the same. The internalName is just a convenience for finding objects inside a list without polluting the global namespace, as in "SomeSet-->GivenInternalName.doSomething();".
11/13/2009 (10:37 pm)
There is no difference in the syntax at all. The only difference, like Ronnie said, is the functions available (specific to the engines themselves).Also, the naming convention works the same. The internalName is just a convenience for finding objects inside a list without polluting the global namespace, as in "SomeSet-->GivenInternalName.doSomething();".
#7
11/13/2009 (10:57 pm)
Wait so the example Greg gave is incorrect or isn't considered syntax but a function or other category? I'm slightly confused now.
#8
I think the "internalName" was added in a later version of TGB (at least I never remember it being in TGE). If an object is in a SimSet/SimGroup, you can find it by its internalName using the function "WhateverSimSet.findObjectByInternalName( <name>, [searchChildren]);". There was also the added operations "->" and "-->". The first searches only children; the second recursively searches sets included in other sets. This would be an example of a trivially small difference between the engines.
I can promise that 99.99% of what you know about TorqueScripting in TGE or TGB will translate to the other.
11/14/2009 (2:24 am)
I'm certain that the "new ObjectType(WhateverName) {};" works in TGE as I use it all the time. It's been a while since I've used TGE, but it behaves the same, kind of like a global object.I think the "internalName" was added in a later version of TGB (at least I never remember it being in TGE). If an object is in a SimSet/SimGroup, you can find it by its internalName using the function "WhateverSimSet.findObjectByInternalName( <name>, [searchChildren]);". There was also the added operations "->" and "-->". The first searches only children; the second recursively searches sets included in other sets. This would be an example of a trivially small difference between the engines.
I can promise that 99.99% of what you know about TorqueScripting in TGE or TGB will translate to the other.
#9
11/14/2009 (5:12 pm)
Alright, thanks for the clarification Will. Thanks for all the help everyone, this more or less clears up my confusion. Take it easy.
#10
You can use internalName in TGE as well, including findObjectByInternalName() -- TGE is just lacking that particular shorthand for setting the internalName upon creation.
As I understand it, there are also a few more changes in T3D (I don't have T3D, so I don't know for sure) that I assume will make it into T2D as well, such as the "singleton" keyword for defining an object (rather than "new" or "datablock"). I don't have much information on that, but I would guess that's also another shorthand.
11/14/2009 (8:32 pm)
Yes, regular "new" works just fine in TGE; it was specifically that particular syntax which included the [ ] (which sets the internalName, rather than the object name) that was new for TGB.You can use internalName in TGE as well, including findObjectByInternalName() -- TGE is just lacking that particular shorthand for setting the internalName upon creation.
As I understand it, there are also a few more changes in T3D (I don't have T3D, so I don't know for sure) that I assume will make it into T2D as well, such as the "singleton" keyword for defining an object (rather than "new" or "datablock"). I don't have much information on that, but I would guess that's also another shorthand.
#11
11/14/2009 (10:45 pm)
Ah! I missed the brackets! Thanks for clarifying that (and I learned something new)!
#12
With the old way its possible to overwrite existing datablocks which if it happens in a multiplayer environment (as it will finally exist with T2D too), causes hard to debug issues and that all just because you forgot a script from long ago that has the same datablock as a new one you just created.
With singleton it won't be overwritten, if it is already there, its kept alive. Just as the singleton pattern in general programming.
As for the differences between TGE and TGB: TGB is about the only TGE descendant technology that got the datablock handling rewritten (as the networking is cut aside of the server / client commands and the TCPObject hierarchy) which has its consequences on some things especially the datablock - inheritance side. Other than that it has naturally significantly more scripting capabilities as TGB was designed to be used just with scripting, unlike all 3D torques that are primarily source technologies with "script modding support"
11/15/2009 (2:15 pm)
singleton datablocks are just "will only exist once" datablocks simply put.With the old way its possible to overwrite existing datablocks which if it happens in a multiplayer environment (as it will finally exist with T2D too), causes hard to debug issues and that all just because you forgot a script from long ago that has the same datablock as a new one you just created.
With singleton it won't be overwritten, if it is already there, its kept alive. Just as the singleton pattern in general programming.
As for the differences between TGE and TGB: TGB is about the only TGE descendant technology that got the datablock handling rewritten (as the networking is cut aside of the server / client commands and the TCPObject hierarchy) which has its consequences on some things especially the datablock - inheritance side. Other than that it has naturally significantly more scripting capabilities as TGB was designed to be used just with scripting, unlike all 3D torques that are primarily source technologies with "script modding support"
#13
11/16/2009 (12:58 pm)
TGPGTT is a great resource for learning torqueScript for any of the various torque engines.
Torque 3D Owner Ronny Bangsund
Torque Cheerleaders