Game Development Community

Auto-load missions in 1.4?

by Rodney (OldRod) Burns · in Torque Game Engine · 12/01/2005 (11:05 am) · 3 replies

I had my project set so that when I clicked a button, it skipped the mission selection list and went straight into a mission that I wanted it to.

I had this in mainMenuGui.gui:

new GuiButtonCtrl() {
      profile = "GuiButtonProfile";
      horizSizing = "right";
      vertSizing = "top";
      position = "36 237";
      extent = "110 20";
      minExtent = "8 8";
      visible = "1";
      //command = "Canvas.setContent(StartMissionGUI);";  <-- original line
      command = "SM_StartMission();";        <-- changed it to this
      text = "Enter World...";
      groupNum = "-1";
      buttonType = "PushButton";
         helpTag = "0";
   };

Then at the bottom of the same file, I had:

function SM_StartMission()
{
   if ($pref::HostMultiPlayer)
      %serverType = "MultiPlayer";
   else
      %serverType = "SinglePlayer";

   createServer(%serverType, "kwm/data/missions/arlenhills.mis");
   %conn = new GameConnection(ServerConnection);
   RootGroup.add(ServerConnection);
   %conn.setConnectArgs($pref::Player::Name);
   %conn.setJoinPassword($Client::Password);
   %conn.connectLocal();
}

In 1.3 this worked fine. In 1.4 I click the button and get a loading screen, but without any mission information and it just hangs there. Did something change that prevents this from working? Or is there a better way to do this?

#1
12/01/2005 (11:28 am)
When you say hang, is it still responding to input, or is it actually frozen? If the latter, run it in a debugger!

Make sure you have a debug build, it will give much more informative error messages.
#2
12/01/2005 (11:35 am)
No, I can hit the cancel button and return to the menu. It's like it's not finding the mission file, but the path is correct. I even tried explicitly putting the full path in and that didn't change it.

Putting the original button code back works and I can load the mission that way, so the mission file itself is ok.

*edit* I just looked in the console.log and I see:

"createServer: mission name unspecified"
#3
12/01/2005 (12:27 pm)
Bah, never mind. It was a stupid mistake on my part :(

I had moved the SM_StartMission() function to mainMenuGUI.gui, but forgot to remove startMissionGUI.gui from the project - it was still trying to run from there.

Just ignore me :)