Game Development Community

Display Gui when entering game

by Jeff Trier · in Torque Game Engine · 03/13/2003 (5:27 am) · 11 replies

Hi all,

Firstly, thanks a ton for all your help. I pretty much just started with Torque less than a week ago, and through your help I already have Custom Spawnable Vehicles, Custom Weapons, Custom Controls, Team Selection and I have created my first scripted Gui.

Secondly, Doh! I can't seem to get the team selection gui to come up when the player enters the game. As it is, I can press a key and have it display. But I would love it if I could have it just appear and save the player from having to initiate it.

I am using script from Xavier Amado's team scripting tutorial located here.

I am not sure where to insert Canvas.pushDialog(TeamSelectDlg);.

Thanks again guys!
-Jeff

About the author

Originally a Classical/Metal musician, I've always been attracted to anything involving computers, including: Networking, PC Building and Repair, software design and coding. I've been involved with game design and development for over 10 years.


#1
03/13/2003 (6:13 am)
look around the scripts to find where the PlayGui is set (Canvas.setContent(PlayGui);)
#2
03/13/2003 (6:39 am)
Is Canvas.pushDialog(TeamSelectDlg); the command I would use to initiate the dialog from a function? I did a search on PlayGui and found this function below.


function GameConnection::prepDemoPlayback(%this)
{
   for(%i = 0; %i < %this.demoChatLines; %i++)
      HudMessageVector.pushBackLine(%this.demoChatText[%i], %this.demoChatTag[%i]);
   Canvas.setContent(PlayGui);
}

Then after inserting it above and below PlayGui, I did a search on GameConnection and tried adding it to GameConnection::onConnect. No luck there.

Sorry if I am being lame, but I am a bit new on how some of this code works (I read the docs though! :) ).


-Jeff
#3
03/13/2003 (6:45 am)
Search for this little bugger ;)

GameConnection::initialControlSet(%this)

read the comments in and around it :)
#4
03/13/2003 (6:47 am)
Glancing over the scripts

In serverConnection.cs try:
//----------------------------------------------------------------------------
// GameConnection client callbacks
//----------------------------------------------------------------------------

function GameConnection::initialControlSet(%this)
{
   echo ("*** Initial Control Object");

   // The first control object has been set by the server
   // and we are now ready to go.
   
   // first check if the editor is active
   if (!Editor::checkActiveLoadDone())
   {
      if (Canvas.getContent() != PlayGui.getId())
         Canvas.setContent(PlayGui);
      [b]Canvas.pushDialog(TeamSelectDlg);[/b]
   }
}

Not exactly sure if that is the best place but it should work.


edit: Code format was off some.
#5
03/13/2003 (6:50 am)
Yup :)

was just attempting to get Jeff to find the function and figure it out, think it is more helpful that way then to give the answer directly *shrug*

-Ron

Jeff,

I tossed yah some email as well
#6
03/13/2003 (6:51 am)
Thanks Ron I did the search, inserted it, and it worked! The player has to make a selection before he sees that chat, but ah well... I can fix that later. :)

Edit:

Doh! Thanks Bruce :)
#7
03/13/2003 (6:54 am)
Well Ron, you should be happy to know that is what I did... hehe.

To be honest I prefer that method too, as long as the community doesn't mind my being lame and not catching on now and then. I want to learn how to catch that fish. ;)


Thanks again!
-Jeff
#8
03/13/2003 (6:54 am)
I understand what you are trying to do, but I figure why have someone search and search, when he obviously understands what needs to be added but can't figure out where.

Is how I would like someone to answer a question of mine anyhow.
#9
03/13/2003 (6:56 am)
I appreciate that Bruce.

Thanks man...

-Jeff
#10
03/13/2003 (7:06 am)
@Bruce

No worries mate :) I agree with your style as well. Just felt like giving Jeff the spoon to feed himself vice spoon feeding him ;)


-Ron
#11
12/14/2005 (8:29 pm)
Jeff did you ever work this out?
I am using torque 1.4 and this all works great until the player decides to switch teams.

every time %client.player.delete(); is called from the leaveteam() function the initialcontrolset function is called on the client side.

So here is what happens after a player has already selected a team and wants to switch:
The player presses M to bring up the selectteam dialog
The player chooses the other team
The select team dialog is destroyed
the player object is deleted
the initialcontrolset function on the client side serverconnections.cs is called
the selectteam dialog appears again because canvas.pushdialog is called from the initialcontrolset funnction.
The only way it goes away is if the player selects the same team twice in a row, if the player chooses the opposite team every time the dialog comes up, you end up in an endless loop.
Has anyone else had this problem? Did i miss something?
Is player.delete implemented differently in 1.4?