Updated: Wading into the scary murky waters of TorqueScript...
by Mitovo · in Torque 3D Beginner · 04/06/2014 (6:30 am) · 17 replies
Hello all,
So, this post had originally been to ask if I should dive straight into T3D to learn TorqueScript, or if I should learn the TGE version contained in the original "3D Game Programming All In One" from Ken Finney.
Since that post, I've stumbled across a newer 3rd Edition which released much more recently, and seems to be based around T3D and more up-to-date tools and techniques. This is a good thing.
This now changes my question, however.
Has anyone worked with this book before, and can they verify the accuracy of its contents, since T3D has gone MIT license and things have been changing. Are the core details and such still relevant to this version?
I'll readily buy the 3rd edition and start learning with it (I really like the setup and comprehensiveness of the 1st edition). I just want to make sure it'll be a good place to start.
Thanks!
So, this post had originally been to ask if I should dive straight into T3D to learn TorqueScript, or if I should learn the TGE version contained in the original "3D Game Programming All In One" from Ken Finney.
Since that post, I've stumbled across a newer 3rd Edition which released much more recently, and seems to be based around T3D and more up-to-date tools and techniques. This is a good thing.
This now changes my question, however.
Has anyone worked with this book before, and can they verify the accuracy of its contents, since T3D has gone MIT license and things have been changing. Are the core details and such still relevant to this version?
I'll readily buy the 3rd edition and start learning with it (I really like the setup and comprehensiveness of the 1st edition). I just want to make sure it'll be a good place to start.
Thanks!
About the author
#2
Well, that's a bummer, about the 3rd edition. Thanks for the heads up on that.
Though, in looking around the website here, I'm finding a lot of resources and info that I had not seen in previous visits. Either people have been busy, or I somehow missed a lot in previous visits.
I'm intending to go through the tutorials offered here. Though, considering my first game project(s) are going to be smaller and simpler than a FPS or anything like that (more in line with top-down shooters, etc), I'm sure the knowledge I gain from them will be transferable to my own projects.
I'll be sure to ask here when ever I hit any walls. I've had some run-ins with T3D's quirks in the past, so I know I'll hit them. But, I'll worry about those when/if they happen.
I've seen a number of books out there for Torque.. including Torque for Teens, though I wasn't aware of what version of the engine it covers. GG and the Torque engine have been through so many changes in the past several years that I imagine writing a book for any one version has been tricky. Perhaps we'll start seeing more books about it coming out now for the MIT version.
As for being long-winded, hey no problem. You should see some of my posts when I really get on a roll :).
Thanks!
04/06/2014 (3:55 pm)
Thanks for the reply!Well, that's a bummer, about the 3rd edition. Thanks for the heads up on that.
Though, in looking around the website here, I'm finding a lot of resources and info that I had not seen in previous visits. Either people have been busy, or I somehow missed a lot in previous visits.
I'm intending to go through the tutorials offered here. Though, considering my first game project(s) are going to be smaller and simpler than a FPS or anything like that (more in line with top-down shooters, etc), I'm sure the knowledge I gain from them will be transferable to my own projects.
I'll be sure to ask here when ever I hit any walls. I've had some run-ins with T3D's quirks in the past, so I know I'll hit them. But, I'll worry about those when/if they happen.
I've seen a number of books out there for Torque.. including Torque for Teens, though I wasn't aware of what version of the engine it covers. GG and the Torque engine have been through so many changes in the past several years that I imagine writing a book for any one version has been tricky. Perhaps we'll start seeing more books about it coming out now for the MIT version.
As for being long-winded, hey no problem. You should see some of my posts when I really get on a roll :).
Thanks!
#3
Other than that, the syntax itself is about the same if not even *the* same.
04/06/2014 (4:07 pm)
TorqueScript has not changed much since TGE. The main differences are the new features such as a foreach loop that lets you iterate through simgroups/simsets and a word list. There is also a -> and a --> operator that lets you access internal name'd objects. Look at the documentation on those.Other than that, the syntax itself is about the same if not even *the* same.
#4
04/06/2014 (4:45 pm)
Agreed - Torquescript itself is relatively unchanged. Each version of the engine changes the interface a little (or a lot) but you can always dig in the relevant engine source files for script bindings.
#5
So do you guys think it'd be worth going through the 1st Edition of the 3D Game Programming book, just to get a hang of it in the context of larger scale projects?
I don't mind going back to TGE in order to learn it. I have a soft spot for that engine lol.
In looking around, I see a few tutorials that seem good based on T3D. None quite so expansive as the book's lessons, though.
By the way, Richard... I swear every time I see your picture, I think you're actually the guy from that Taxi game show lol.
04/06/2014 (6:04 pm)
Hmm... So do you guys think it'd be worth going through the 1st Edition of the 3D Game Programming book, just to get a hang of it in the context of larger scale projects?
I don't mind going back to TGE in order to learn it. I have a soft spot for that engine lol.
In looking around, I see a few tutorials that seem good based on T3D. None quite so expansive as the book's lessons, though.
By the way, Richard... I swear every time I see your picture, I think you're actually the guy from that Taxi game show lol.
#6
If you're learning in TGE just remember that the functions that you call stand a pretty good chance of being different in T3D. The programming language is the same, but the engine-side interface is different. It will take a little while to transition back to T3D later.
04/06/2014 (9:18 pm)
lol - I was goofing around with my daughter and her camera in like '06.If you're learning in TGE just remember that the functions that you call stand a pretty good chance of being different in T3D. The programming language is the same, but the engine-side interface is different. It will take a little while to transition back to T3D later.
#7
04/06/2014 (9:44 pm)
Quote:you can always dig in the relevant engine source files for script bindings....if you're a wizard and know how to parse, in your head, the messiest BNF grammar I've ever read ;P.
#8
Gotta remember, I'm completely new to all this, so I wouldn't know where to even begin looking for differences between them. I'm about as green as green can be at this point.
Okay, then I'll nix the idea of going the TGE approach and just stick with T3D.
Thanks!
04/07/2014 (5:41 am)
Ah, okay.. So there *are* significant differences, then. Gotta remember, I'm completely new to all this, so I wouldn't know where to even begin looking for differences between them. I'm about as green as green can be at this point.
Okay, then I'll nix the idea of going the TGE approach and just stick with T3D.
Thanks!
#9
http://www.amazon.com/Torque-3D-Game-Development-Cookbook/dp/1849693544
04/07/2014 (4:17 pm)
Wouldn't Dave Wyand's cookbook be the most up to date?http://www.amazon.com/Torque-3D-Game-Development-Cookbook/dp/1849693544
#10
I've seen that book, but it seems like it's intended for people who already have understanding of scripting and such with Torque, so it's not quite beginner level.
Although I'm not sure, really, what previous knowledge they assume of the reader with that book...
Maybe I'll see if my local B&N has a copy and thumb through it.
04/07/2014 (5:31 pm)
@NiN...I've seen that book, but it seems like it's intended for people who already have understanding of scripting and such with Torque, so it's not quite beginner level.
Although I'm not sure, really, what previous knowledge they assume of the reader with that book...
Maybe I'll see if my local B&N has a copy and thumb through it.
#11
I've been going through the tutorials, and even just part way through the Functions tutorial, I'm already kinda lost.
I'm typing stuff in, and it's working as it's supposed to, but it's not explaining why things are entered as they are and/or when I'd do something similar in my own projects. And that's really what I need to know if I'm to learn this stuff.
Specifically, there's this bit...
I recognize that %part1 and %part2 would be global variables. However, I'm also aware that variables are supposed to be defined before they're called elsewhere in the program, or it won't work.
Yet, in this case, they're being called first, and then being defined later when the second part is entered in the console... and it's working fine.
Why is that okay in this case, when in others it wouldn't be?
That isn't explained, which leaves me confused, because it contradicts what I'd learned about variables previously.
It seems to be a thing with just about any tutorials I read on programming/scripting, that the authors inevitably forget they're speaking to an audience who may well know nothing about the subject, and end up making too many assumptions of what they already know or understand.
So, I need to find a book that is going to break this down to the absolute basics, assuming nothing more than "you're brand-new to programming/scripting, and everything has to be explained".
Either that, or I need a really good teacher/tutor to help me out lol.
04/08/2014 (3:01 pm)
So, I'm gonna have to find a good book, or alternate source, to learn TorqueScript, I think.I've been going through the tutorials, and even just part way through the Functions tutorial, I'm already kinda lost.
I'm typing stuff in, and it's working as it's supposed to, but it's not explaining why things are entered as they are and/or when I'd do something similar in my own projects. And that's really what I need to know if I'm to learn this stuff.
Specifically, there's this bit...
Quote:
// Print two separate strings to the console
// Equally redundant in equality
// %part1 - First part of message
// %part2 - Second part of message
function printAdvancedMessage(%part1, %part2)
{
echo(%part1, %part2);
}
Run the game and type the following in the console:
printAdvancedMessage("Singin: dont worry about a thing,", "ncause every little thing gonna be all right");
I recognize that %part1 and %part2 would be global variables. However, I'm also aware that variables are supposed to be defined before they're called elsewhere in the program, or it won't work.
Yet, in this case, they're being called first, and then being defined later when the second part is entered in the console... and it's working fine.
Why is that okay in this case, when in others it wouldn't be?
That isn't explained, which leaves me confused, because it contradicts what I'd learned about variables previously.
It seems to be a thing with just about any tutorials I read on programming/scripting, that the authors inevitably forget they're speaking to an audience who may well know nothing about the subject, and end up making too many assumptions of what they already know or understand.
So, I need to find a book that is going to break this down to the absolute basics, assuming nothing more than "you're brand-new to programming/scripting, and everything has to be explained".
Either that, or I need a really good teacher/tutor to help me out lol.
#12
I think i can explain the above situation but i'd like someone else to confirm this is correct logic
So when function printAdvancedMessage is called it will print out the variables %part1 and %part2
Now you are asking why aren't the variables set but they are
So when you call
You are setting the %part1 and %part two variable on the fly then the function runs the echo with the new variables %part1 and %part2
Also I believe that $variable is a global variable and %variable is a local variable
Hopefully this makes sense and I am correct in my understanding.
04/08/2014 (3:57 pm)
I'm still a beginner and i've only been working my way around by trying different things and seeing how it works or work out why it works like thatI think i can explain the above situation but i'd like someone else to confirm this is correct logic
function printAdvancedMessage(%part1, %part2)
{
echo(%part1, %part2);
}So when function printAdvancedMessage is called it will print out the variables %part1 and %part2
Now you are asking why aren't the variables set but they are
function printAdvancedMessage(%part1, %part2)This says that when printAdvancedMessage is called it will have extra infomation in the format of text, text and it will set that information to %part1, %part2
So when you call
printAdvancedMessage("Singin: dont worry about a thing,", "ncause every little thing gonna be all right");You are setting the %part1 and %part two variable on the fly then the function runs the echo with the new variables %part1 and %part2
Also I believe that $variable is a global variable and %variable is a local variable
Hopefully this makes sense and I am correct in my understanding.
#13
04/08/2014 (4:44 pm)
Let me replace the comments in that with more useful ones:// Combine two separate strings and
// print them to the console
// %part1 - function parameter containing the first part of message
// %part2 - function parameter containing the second part of message
function printAdvancedMessage(%part1, %part2)
{
// This uses the engine-side script command 'echo()' to print
// %part1 and %part2 to the console.
echo(%part1, %part2);
// This would also work:
%all = %part1 SPC %part2;
// uses the SPC keyword to combine the two strings with a space
// between them. TAB adds a tab instead of a space
echo(%all);
}And NIN is correct - $variable is global, %variable is local. In the example above, %part1, %part2, and %all are local to this function and cannot be accessed outside of this function.
#14
So basically...
It's okay if new variables are passed into a function before they've been defined, as long as they're defined when the function itself is called?
I think I said that right lol...
Thank you for explaining it :)
Anyway, I think I'm still going to try and find a book or tutorial series that teaches this in some specific context. Because while I can understand now what's going on in that example, I have absolutely no idea when or why I would do something like that. Basically, "Okay, I know I *can* do that... But when or why would I *want* or *need* to do that?".
So yeah.. the search for a project-based book or tutorial series continues...
04/08/2014 (5:03 pm)
Gah... I meant to say Local. Was thinking of Global for some reason. My bad there.So basically...
It's okay if new variables are passed into a function before they've been defined, as long as they're defined when the function itself is called?
I think I said that right lol...
Thank you for explaining it :)
Anyway, I think I'm still going to try and find a book or tutorial series that teaches this in some specific context. Because while I can understand now what's going on in that example, I have absolutely no idea when or why I would do something like that. Basically, "Okay, I know I *can* do that... But when or why would I *want* or *need* to do that?".
So yeah.. the search for a project-based book or tutorial series continues...
#15
f(x) = x * 2
in maths, you mean that when you give the function f a value of x, it returns the value that's twice x. This works for any value of x, that's why x is VARYable. Let's write that in TorqueScript-
So later on you could call f(2), and for that function call, %x would equal 2. Or you could call f(-500), and %x would be -500. In the case of your echo function, you're not returning a value, bu performing some effect which depends on your input variables %part1 and %part2. So when you call printAdvancedMessage("hello", "world"), for that function call, %part1 is "hello" and %part2 is "world", and the effect is that "helloworld" gets echoed to the console.
*As much as it hurts me to say this when talking about imperative languages :P.
EDIT: It's unfortunate that most literature out there for Torque kind of assumes you already know how to program, and just that you don't know the specifics of TorqueScript. Hang in there! I'd also recommend looking up some basic programming tutorials. They're all over the web! Even learning to program in another language like Python or JavaScript will make using TorqueScript much more comprehensible.
04/08/2014 (7:34 pm)
Hey Mike, I don't know what your background is but are you familiar with functions in maths? Functions in programming have some similarities*. For example, when you writef(x) = x * 2
in maths, you mean that when you give the function f a value of x, it returns the value that's twice x. This works for any value of x, that's why x is VARYable. Let's write that in TorqueScript-
function f(%x) {
return %x * 2;
}So later on you could call f(2), and for that function call, %x would equal 2. Or you could call f(-500), and %x would be -500. In the case of your echo function, you're not returning a value, bu performing some effect which depends on your input variables %part1 and %part2. So when you call printAdvancedMessage("hello", "world"), for that function call, %part1 is "hello" and %part2 is "world", and the effect is that "helloworld" gets echoed to the console.
*As much as it hurts me to say this when talking about imperative languages :P.
EDIT: It's unfortunate that most literature out there for Torque kind of assumes you already know how to program, and just that you don't know the specifics of TorqueScript. Hang in there! I'd also recommend looking up some basic programming tutorials. They're all over the web! Even learning to program in another language like Python or JavaScript will make using TorqueScript much more comprehensible.
#16
I figure, maybe understanding Python will help me out a bit with the concepts behind TorqueScript.
For now, though, I'll have to wait and hope someone releases a book or something for TS that's a bit more beginner friendly.
04/08/2014 (7:51 pm)
It's funny you mention that. I've started learning some Python, though not specifically for Torque (of course), but because I can apply it to Blender3D.I figure, maybe understanding Python will help me out a bit with the concepts behind TorqueScript.
For now, though, I'll have to wait and hope someone releases a book or something for TS that's a bit more beginner friendly.
#17
04/08/2014 (9:52 pm)
Quote:I figure, maybe understanding Python will help me out a bit with the concepts behind TorqueScript.It really will. Your first programming language is always the hardest - after that it's mostly a matter of learning new syntax.
Jason Campbell
I do own almost every book on Torque and highly recommend The Game Programmer's Guide to Torque by Edward F. Maurina. Ken Finney's Advanced Game Programming All-in-One. Both are for older versions of Torque but other then NameSpaces and folder setups, the script seems fine. Another book that I thought was well done is Torque for Teens. I know it is for beginners but the parts on terrain, animation and general use is very accurate and useful.
Wow, I'm long winded. Personally I think you could just jump into the Tutorials and learn as you go. When you require some knowledge you can usually find it or ask here for help. The books work best as a reference, for me. If you worked through 3DGPAI1 you would most likely have a leg-up but would need to relearn some stuff. It is a great book, that's why I'm saddened by the 3rd edition.