Game Development Community

Input from the mouse

by Daniel Buckmaster · in Torque Game Engine · 02/20/2007 (10:18 am) · 7 replies

I've searched the forums and documentation, but nowhere does anything actually tell me how the $mvTriggerCount from default.bind.cs is translated into making the player's weapon fire in starter.fps. There's no instruction to do anything within the mouseFire function, except for increasing the trigger count. My first thought was to stick a function in there to make a weapon fire, but that isn't how it's done in starter.fps. Problem is, I can't see how it IS done.

About the author

Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!


#1
02/20/2007 (10:20 am)
Have you searched in the engine code for mvTriggerCount?
That will lead you to your answer.
#2
02/20/2007 (10:30 am)
GameConnectionMoves.cpp @ Line 88.
#3
02/20/2007 (11:28 am)
Okay, I didn't know the engine code was involved with this part of it. So I found that it adds a $mvTriggerCountx variable for every trigger you want to be able to use. But how does Torque use that variable to do anything useful? Is the answer in the source code? There was only one place that the search found a reference to mvTriggerCount...
#4
02/20/2007 (11:40 am)
Keep looking, you gotta follow the trail of variables:

bool GameConnection::getNextMove(Move &curMove)
{
    [b]//...Bunch of prior code[/b]

    for(U32 i = 0; i < MaxTriggerKeys; i++)
   {
      curMove.trigger[i] = false;
      if(MoveManager::mTriggerCount[i] & 1)
         curMove.trigger[i] = true;
      else if(!(MoveManager::mPrevTriggerCount[i] & 1) && MoveManager::mPrevTriggerCount[i] != MoveManager::mTriggerCount[i])
         curMove.trigger[i] = true;
      MoveManager::mPrevTriggerCount[i] = MoveManager::mTriggerCount[i];
   }

That's where the trigger event gets checked and stored....curMove.trigger gets set to true.

You can keep digging until you find your answer....or...is there something you were specifically trying to accomplish, or just trying to learn some of the inner mechanics of TGE?
#5
02/20/2007 (12:51 pm)
Well, I was really just trying to find out how to get the mouse button to do something useful through script. Say, calling function on some object when I click the button.

curMove.trigger[i] - is that available within script? And if so, where should I check it? I'm guessing that the default classes that use mouse events (weapon images) have some sort of checker for this within engine code, but I want to create a different weapon system.
#6
02/20/2007 (1:00 pm)
Oh wow, you are going above and beyond then =)

function doSomethingUseful(%val)
{
    if(%val)
        echo("We are doing something useful");
    else
        echo("Mouse button released");
}

moveMap.bind( mouse, button0, doSomethingUseful );
#7
02/20/2007 (11:49 pm)
Really? Okay, I trust you ;). Seems too simple... on the other hand, I guess that's a god thing. Thanks for the help.

EDIT: And these functions are executed on the client side, right?