Game Development Community

A Little Help Understanding How The Scripting In Torque Works

by James Keir · in Torque Game Engine · 02/16/2006 (8:50 pm) · 5 replies

Hey,
I have been going through the book 3DGPAi1 and got a question about scripting (I searched the forums and foundmost of my answers just want to clarify on a few things). When creating someof the scripts I came across things that i need some clarification on when making the player.cs file (the questions I have are below about the two functions. Theres a few more functions im just using these 2 as an exmaple):

datablock PlayerData(HumanMaleAvatar)
{
className = MaleAvatar;
shapeFile = "~/data/models/avatars/human/player.dts";
emap = true;
......
}

function MaleAvatar::onAdd(%this,%obj)
{
.....
}

and

function HumanMaleAvatar::onImpact(%this,%obj,%collidedObject,%vec,%vecLen)
{
......
}

The first one from what i understand is kinda of a datablock hack by setting a className in the PlayerData datablock. From what i read this enables you to insert code inbetween the player Object and the GameBase (I think its something like that, if im wrong or if you could clarify that would be great). My question is, are these functions used by the engine or by other script files (.cs)? and if the engine calls these how do they know about them?

The second one from what I understand is a callback from the engine (in PlayerData I believe) and is called when a avatar collision happens with the terrian or interiors. My question is where could i find this call back in the code? (I looked in player.cs and found a function call to onImpact() but the parameters didn't match (in one in player.cs had 2 and this one has 4 (the %this parameter is automaticly inserted from what i read)).

I think thats all for now, I have a programming background (mainly VB and Java) just trying to get a handle on C++ and how the scripting works in torque. Thanks for your time and any help/a push in theright direction would be great.

--James

#1
02/17/2006 (10:17 am)
I think i answered one of my questions. I just found that the engine does callbacks using the Con:executef() command. Still any helpwould be apperatied :).

--James
#3
02/17/2006 (11:35 am)
Thanks for the great resource =). It will help me out alot when trying to wrap my head around this stuff. The videos are awesome.

--James
#4
02/17/2006 (11:59 am)
Just have to add the IDE this guy is using rocks and wouldn't have found it if it wasn't for the link. Thanks Again.

--James
#5
02/17/2006 (1:26 pm)
Glad it helped you out, and you're welcome.

B--