Mouse selection for Clients
by Michael Shah · in General Discussion · 09/24/2009 (11:57 am) · 5 replies
Hello Garage Games Community,
I am having trouble with having multiple clients selecting shapes in a networked torque game. Here is an example door shape that I want a specific client to be able to click on and push a dialog onto only their canvas.
function DoorShape::onUseThis(%this, %object,%client)
{
commandToClient(%client, "pushTravelGUI") I think we need to somehow send this pushDialog to a specific client
//canvas.pushDialog(travelGUI);
}
The client function to push the GUI
function pushTravelGUI()
{
canvas.pushDialog(travelGUI) ;
}
Here is the mouse selection code I am using to try to figure out which object was selected, by which client.
function serverCmduseSelectedObject(%client)
{
echo("Server Cmd use Selected Object is being used by :") ;
echo(%client.getName()) ;
%useObject = %client.getSelectedObject();
%name = %useObject.getName();
echo("is using object: ") ;
echo(%name) ;
%useObject.onUseThis(%useObject, %client) ;
}
Thank you for your help.
I am having trouble with having multiple clients selecting shapes in a networked torque game. Here is an example door shape that I want a specific client to be able to click on and push a dialog onto only their canvas.
function DoorShape::onUseThis(%this, %object,%client)
{
commandToClient(%client, "pushTravelGUI") I think we need to somehow send this pushDialog to a specific client
//canvas.pushDialog(travelGUI);
}
The client function to push the GUI
function pushTravelGUI()
{
canvas.pushDialog(travelGUI) ;
}
Here is the mouse selection code I am using to try to figure out which object was selected, by which client.
function serverCmduseSelectedObject(%client)
{
echo("Server Cmd use Selected Object is being used by :") ;
echo(%client.getName()) ;
%useObject = %client.getSelectedObject();
%name = %useObject.getName();
echo("is using object: ") ;
echo(%name) ;
%useObject.onUseThis(%useObject, %client) ;
}
Thank you for your help.
About the author
Uses Torque for Research
#2
I'm working with Michael Shah as well. We used your resource and got it to work. So it keeps track of which client has selected what. We added some simple functionality for being able to use selected objects. We're having trouble with basically it seems maybe some torquescript syntax and the arguments we're getting aren't what they're supposed to be or it ends up continually being the server as the client so something isn't working there.
Thanks,
Eddie
09/25/2009 (12:29 pm)
Hi Ted,I'm working with Michael Shah as well. We used your resource and got it to work. So it keeps track of which client has selected what. We added some simple functionality for being able to use selected objects. We're having trouble with basically it seems maybe some torquescript syntax and the arguments we're getting aren't what they're supposed to be or it ends up continually being the server as the client so something isn't working there.
Thanks,
Eddie
#3
09/25/2009 (12:47 pm)
@Edward: I don't have a code resource that I've developed- I use the Dave Myers one myself (I may have posted some porting code in the past). Do you have more information? A link to the resource you're using and maybe some script that shows what you're doing and the errors it's showing? Otherwise, I don't know what the problem is. Thanks.
#4
A rundown would be.
1. Player Selects object and object becomes highlighted
2. Player presses 'f' our key for using an object binded so
moveMap.bind(keyboard, "f", "commandToServer('useSelectedObject');") ;
3. Calls Server command useSelectedObject with correct client and object
function serverCmduseSelectedObject(%client)
{
%useObject = %client.getSelectedObject();
%name = %useObject.getName();
%useObject.onUseThis(%useobject, %client) ;
}
4. In the instance of the door
function DoorShape::onUseThis(%this, %object, %client)
{
commandToClient(%client, 'PushTeleportGui');
}
5. Which should call
function clientCmdClientPushTeleportGui()
{
Canvas.pushDialog(travelGui) ;
}
What goes wrong is that this syntax causes an fatal error on game startup in guicontrol.cpp with message
GuiControlProfile: unable to find specified profile (GuiDefaultProfile) and GuiDefault Profile does not exist.
The Doorshape object is a datablock we created and travelGUI is a gui dialog.
I've also tried a variation where onUseThis only takes the client argument and the same error occurs.
09/25/2009 (1:37 pm)
I must be mistaken then. I confirm that the mouse object selection works and that each client is saving the object they have selected. The problem is that in a networked game, when two players join and uses the 'Door' object it should push a Dialog on their computer. What happens is instead the dialog is only pushed on the host machine, even if the other player uses it. A rundown would be.
1. Player Selects object and object becomes highlighted
2. Player presses 'f' our key for using an object binded so
moveMap.bind(keyboard, "f", "commandToServer('useSelectedObject');") ;
3. Calls Server command useSelectedObject with correct client and object
function serverCmduseSelectedObject(%client)
{
%useObject = %client.getSelectedObject();
%name = %useObject.getName();
%useObject.onUseThis(%useobject, %client) ;
}
4. In the instance of the door
function DoorShape::onUseThis(%this, %object, %client)
{
commandToClient(%client, 'PushTeleportGui');
}
5. Which should call
function clientCmdClientPushTeleportGui()
{
Canvas.pushDialog(travelGui) ;
}
What goes wrong is that this syntax causes an fatal error on game startup in guicontrol.cpp with message
GuiControlProfile: unable to find specified profile (GuiDefaultProfile) and GuiDefault Profile does not exist.
The Doorshape object is a datablock we created and travelGUI is a gui dialog.
I've also tried a variation where onUseThis only takes the client argument and the same error occurs.
#5
Well, that's a problem, since many gui controls use that profile. Do a search for it in the project, and if it doesn't exist, you can pull it from a fresh copy of the engine and paste it into the correct profiles script. You'll want to get past that error before you troubleshoot anything else. Hope that helps.
09/25/2009 (2:57 pm)
Quote:GuiControlProfile: unable to find specified profile (GuiDefaultProfile)
Well, that's a problem, since many gui controls use that profile. Do a search for it in the project, and if it doesn't exist, you can pull it from a fresh copy of the engine and paste it into the correct profiles script. You'll want to get past that error before you troubleshoot anything else. Hope that helps.
Torque 3D Owner Ted Southard