How to determine the parameters in functions like onCollision?
by Paulo Egidio · in Torque Game Engine · 10/30/2005 (7:11 am) · 9 replies
I'm getting around to prototyping my first game to learn torque, but one thing that's slowing me down is how to determine the parameters of funtions like onCollision(for example).
Is it onCollision(%this) ? , onCollision(%this, %obj) ? onCollision(%this,%obj,%col)? etc...
I've tried every one of them and they don't give compile errors, and some work, some don't....
Is there a doc telling which/how many params is expected?
Do I have to look the source code up to come up with this?
Help ; )
Is it onCollision(%this) ? , onCollision(%this, %obj) ? onCollision(%this,%obj,%col)? etc...
I've tried every one of them and they don't give compile errors, and some work, some don't....
Is there a doc telling which/how many params is expected?
Do I have to look the source code up to come up with this?
Help ; )
About the author
#2
Thanks! But ConsoleMethod dosen't help here, since OnCollision isn't a funciton exported via a ConsoleMethod(). I found the code, but it didn't help much though... any other thoughts?
Anybody else want a crack at this?
Thanks
10/31/2005 (5:17 am)
@Josh:Thanks! But ConsoleMethod dosen't help here, since OnCollision isn't a funciton exported via a ConsoleMethod(). I found the code, but it didn't help much though... any other thoughts?
Anybody else want a crack at this?
Thanks
#3
shapeBase.cc line 2825 has this...
Con::executef(mDataBlock,5,"onCollision",scriptThis(),object->scriptThis(), buff1, buff2);
So for shape base objects in code.....things like player will have a function onCollision called with 5 parameters.
You can look at this code section and see what it does....
here are my guess....
%this pointer is the pointer to the datablock
%obj is the object that is being collided with i.e. your player character
%col is the object that is doing the colliding i.e. your rocket
%buff1 is the vector of collision i.e. the rocket path
%buff2 is the scale of the vector i.e. the amount of force.
again this is all just my guesses for using torque for 2 months.
11/02/2005 (10:18 pm)
I just did a search through the torque engine for onCollision....you can see where the script function gets called....for example...shapeBase.cc line 2825 has this...
Con::executef(mDataBlock,5,"onCollision",scriptThis(),object->scriptThis(), buff1, buff2);
So for shape base objects in code.....things like player will have a function onCollision called with 5 parameters.
You can look at this code section and see what it does....
here are my guess....
%this pointer is the pointer to the datablock
%obj is the object that is being collided with i.e. your player character
%col is the object that is doing the colliding i.e. your rocket
%buff1 is the vector of collision i.e. the rocket path
%buff2 is the scale of the vector i.e. the amount of force.
again this is all just my guesses for using torque for 2 months.
#4
Thanks! What baffled me was the buf1 and buf2 params.
Some more through documentation from GG(Like the book they once said they'd publish) would be nice....
11/03/2005 (4:54 am)
@Josh:Thanks! What baffled me was the buf1 and buf2 params.
Some more through documentation from GG(Like the book they once said they'd publish) would be nice....
#5
11/07/2005 (2:24 pm)
Ive been wondering the same thing, ive only been learning torque for 2 or 3 weeks, and im really getting slowed down trying to look up what pre existing functions and code objects there are and how they work. C++ comes with huge charts that detail its standard library, and in the code editor it gives you a list of posible parameters when an object is reffered to. I dont expect torque to have all that just because C++ does, but is there a text document or an index somewhere atleast?
#6
Find in files is also valuable - as you can see a question like "how does onCollision" work can get answered very quickly.
Meanwhile on the doc front, there are two excellent books by Ken Finney on how to use Torque, as well as an upcoming title from Ed Maurina (and you can preview parts of his work online). We've also recently launched a preview of the Torque Developer Network, which is a wiki-based documentation site. There's a good source code reference online if you're curious about how classes relate or what members there are, and it's indexed by our google mini, so you can quickly find things. And we have even better code reference stuff coming out soon, thanks to Tom Bampton's hard work - keep your eyes open for a beta release of that, too.
A book from us would be a little silly - by the time we got it published it would be out of date. :)
We also offer 3-day Torque Bootcamps, both for indies and for people with greater finances, and naturally there's a vast amount of knowledge on the forums here.
11/07/2005 (6:26 pm)
Well, intellisense works just as well with Torque as with the standard libs. Autocomplete, find definition etc. all work just fine for me. (I use VC7.1, with Visual Assist for added mojo.)Find in files is also valuable - as you can see a question like "how does onCollision" work can get answered very quickly.
Meanwhile on the doc front, there are two excellent books by Ken Finney on how to use Torque, as well as an upcoming title from Ed Maurina (and you can preview parts of his work online). We've also recently launched a preview of the Torque Developer Network, which is a wiki-based documentation site. There's a good source code reference online if you're curious about how classes relate or what members there are, and it's indexed by our google mini, so you can quickly find things. And we have even better code reference stuff coming out soon, thanks to Tom Bampton's hard work - keep your eyes open for a beta release of that, too.
A book from us would be a little silly - by the time we got it published it would be out of date. :)
We also offer 3-day Torque Bootcamps, both for indies and for people with greater finances, and naturally there's a vast amount of knowledge on the forums here.
#7
I'm getting close to finishing a really beta stage of my game.
Getting networking up now. Then I'm off to making my art look better and implement some other features.
Since this game is supposed to be free just so I can get a handle on Torque and it's massive content(and show ourselfs to the Brazilian market), I think it's gonna hit the spot.
11/08/2005 (3:31 am)
@Ben : Thanks Ben. I really meant how to determine the parameters in TorqueScript, not in C++, but I think I've got the hang of it with the replies that have been given here.I'm getting close to finishing a really beta stage of my game.
Getting networking up now. Then I'm off to making my art look better and implement some other features.
Since this game is supposed to be free just so I can get a handle on Torque and it's massive content(and show ourselfs to the Brazilian market), I think it's gonna hit the spot.
#8
Good luck with your game!
11/08/2005 (11:48 am)
In debug mode, if you call a function with no params it will tell you the parameters. There're also dumpConsoleClassess() and dumpConsoleFunctions() calls that will list all functions and classes defined in the engine, including script defined ones. Tools like Torsion are also going to be helpful, too.Good luck with your game!
#9
Thanks a bunch.... BTW, about the book... I think I can live without one as this community and GG developers rock and really give out help when needed.
Thanks. You've got one returning customer, thats for sure!
11/08/2005 (11:58 am)
@Ben: AHH!! That really helps!Thanks a bunch.... BTW, about the book... I think I can live without one as this community and GG developers rock and really give out help when needed.
Thanks. You've got one returning customer, thats for sure!
Torque Owner Josh "GimpMaster" Hintze