Game Development Community

Action Map pop() and push() not working correctly

by Ronald J Nelson · in Torque Game Engine · 08/18/2007 (4:11 pm) · 5 replies

I am quite certain now that I am doing this correctly, as far as I can tell the maps are not being popped. Here is what I have:

function Armor::onMount(%this,%player,%vehicle,%node)
{
   if (%node == 0)  
   {
      %client = %player.getControllingClient();
      %player.setTransform(%vehicle.getDataBlock().mountPointTransform[%node]);
      %player.setActionThread(%vehicle.getDatablock().mountPose[%node],true,true);
      %player.lastWeapon = %player.getMountedImage($WeaponSlot);
 
      echo("The vehicle mapping has been pushed");
      CommandToClient(%client, 'PopActionMap', moveMap);
      CommandToClient(%client, 'PushActionMap',vehicleDriverMap);
 
      %player.unmountImage($WeaponSlot);
      %client.setControlObject(%vehicle);
 
      // Update the camera to start with the player
      echo("This is onMount %client: " @ %client);
      echo("This is onMount %player: " @ %player);
      echo("This is onMount %vehicle: " @ %vehicle);
      echo("This is onMount %node: " @ %node);
 
      %client.camera.setTransform(%vehicle.getEyeTransform());
   }
}
 
function clientCmdPopActionMap(%map)
{
   echo("Popping action map " @ %map);
   %map.pop();
}
 
function clientCmdPushActionMap(%map)
{
   echo("Pushing action map " @ %map);
   %map.push();
}
 
moveMap.bind( keyboard, "e", getIn );
vehicleDriverMap.bind(keyboard, "e", getOut);
 
function getIn( %val )
{
   if ( %val )
      commandToServer('MountVehicle');
}
 
function getOut( %val )
{
   echo("Client getOut function called");
   commandToServer('DismountVehicle');
}

Even though I am seeing this in the consolelog:
Mapping string: PopActionMap to index: 18
Popping action map moveMap
Mapping string: PushActionMap to index: 19
Pushing action map vehicleDriverMap

IT IS NOT CHANGING THE MAPPING!!!

My testing has shown that both maps are present (checked using functions unique to the individual ActionMaps), but the popping never took place because the mapping that should have been replaced, is not.

#1
08/18/2007 (7:56 pm)
I'm using a very similar method and it works fine. Your scripts look okay to me, maybe the problem resides with your vehicleDriverMap?

Make sure it's being executed and that there are no errors that would prevent it from compiling.

At the top of the script, you should have something like this defined:
// vehicleDriverMap.cs

if ( isObject( vehicleDriverMap ) )
   vehicleDriverMap.delete();
new ActionMap(vehicleDriverMap);
#2
08/18/2007 (8:10 pm)
Yeah figured something out. If I type moveMap.pop(); in the console, it all works. So apparently it wasn't popping as it should.
#3
08/18/2007 (8:37 pm)
Found it.

There was a moveMap.push(); in playGui.cs that was the source of my problems. Commented it out and all works perfectly.

Thanks.
#4
08/18/2007 (8:40 pm)
Strange, the moveMap.push(); in playGui.cs doesn't interfere with my vehicle system. If you take that out, how is the main player map being pushed upon commencing a game?
#5
08/18/2007 (11:49 pm)
Since in my game you spawn mounted to a vehicle it happens during the mount process.