Where to Find Documentation on Recording Trigger Counts
by Thomas Phillips · in Torque Game Engine · 09/30/2006 (9:52 pm) · 6 replies
In the starter.fps, the left mouse button is captured like so:
function mouseFire(%val)
{
$mvTriggerCount0++;
}
As I understand it, there is some magic that translates $mvTriggerCount0 into an array on the server, and then something acts on that array. However, I haven't been able to find anything that documents this. Could someone point me to some documentation that describes how these events are being sent over, and what is reading the results on the server?
Tom
function mouseFire(%val)
{
$mvTriggerCount0++;
}
As I understand it, there is some magic that translates $mvTriggerCount0 into an array on the server, and then something acts on that array. However, I haven't been able to find anything that documents this. Could someone point me to some documentation that describes how these events are being sent over, and what is reading the results on the server?
Tom
#2
Thanks for the link. A search returning that post from May 2004 is actually what hinted me to the array connection.
Unfortunately, it didn't seem to provide any other information on this. I've also dug through lots of code, and the following is another hint:
What I'm really looking for is some documentation to go with these snippets. There's lots of stuff scatted through the Garage Games web site, and I just haven't been able to find what I'm looking for using simple keyword searches.
Tom
10/01/2006 (2:11 pm)
@PhilippeThanks for the link. A search returning that post from May 2004 is actually what hinted me to the array connection.
$mvTriggerCount array, indices 0 through MaxTriggerKeys-1
Unfortunately, it didn't seem to provide any other information on this. I've also dug through lots of code, and the following is another hint:
./game/gameConnectionMoves.cc
for(U32 i = 0; i < MaxTriggerKeys; i++)
{
char varName[256];
dSprintf(varName, sizeof(varName), "mvTriggerCount%d", i);
Con::addVariable(varName, TypeS32, &mTriggerCount[i]);
}What I'm really looking for is some documentation to go with these snippets. There's lots of stuff scatted through the Garage Games web site, and I just haven't been able to find what I'm looking for using simple keyword searches.
Tom
#3
10/02/2006 (11:22 am)
What are you confused about? That code snippet shows what you are looking for. It's creating global variables in script and linking them to the corresponding variables in the array. The dSprintf function gives you a string of "mvTriggerCount%d" where they %d is replaced with the index of the array. Then using that string, you create a script global variable that is linked to the address of the corresponding internal variable using Con::addVariable. This is how all the player actions are read in, you can see simpler versions with all the other actions that don't use arrays, like "Con::addVariable("mvForwardAction", TypeF32, &mForwardAction);", etc.
#4
I was hoping to find documentation on this (thus, the post in the documentation forum) so I wouldn't have to pester folks, but I do appreciate your explanation. I'm now trying to understand how triggers make their way to change the state of an item with a ShapeBaseImageData datablock. I'd like to implement complex devices and believe I understand how to implement the animations and callbacks associated with image states, but haven't yet been able to trace the execution path (through both script and source code) to an actual image state change.
Again, I'd be happy just knowing where to find relevant documentation, but explanations are always welcome. :-)
Tom
10/02/2006 (7:23 pm)
@PaulI was hoping to find documentation on this (thus, the post in the documentation forum) so I wouldn't have to pester folks, but I do appreciate your explanation. I'm now trying to understand how triggers make their way to change the state of an item with a ShapeBaseImageData datablock. I'd like to implement complex devices and believe I understand how to implement the animations and callbacks associated with image states, but haven't yet been able to trace the execution path (through both script and source code) to an actual image state change.
Again, I'd be happy just knowing where to find relevant documentation, but explanations are always welcome. :-)
Tom
#5
As for how they change the images, the only thing they do is have this snippet of code in player.cc in updateMove.
10/03/2006 (11:51 am)
The triggers are closely tied to the networking, they record in the player input and are sent in EVERY packet to the server, as player input is the most important data. How exactly all that works is probably not something you need to worry about.As for how they change the images, the only thing they do is have this snippet of code in player.cc in updateMove.
// Trigger images
if (mDamageState == Enabled) {
setImageTriggerState(0,move->trigger[0]);
setImageTriggerState(1,move->trigger[1]);
}You can look through the shapebase and player classes to see other ways the triggers are read in. Basically a struct called "move" gets sent up to the server and you can parse it in the code to do whatever you want. There is also a script callback set in shapebase, so any class derived from that you can use thefunction (ShapeBaseClass)::onTrigger(%this, %obj, %triggerNum, %val)In you scripts to set any behaviours there. And for most cases, it will be easier to resolve this data in script. The function is already defined in the stock player.cs in starter.fps, though it doesn't have any active script code in it by default.
Torque Owner Philippe C