Game Development Community

How can I automatically start the Mission Editor?

by Greg Bassett · in Torque Game Engine · 01/12/2007 (3:19 am) · 5 replies

I have added loadMyMission(); at the end of the initClient() function in the client\main.cs file to load my mission on startup of TGE.

However I want the Mission Editor to be open automatically on startup of my mission, thus not having to press F11 manually to open the Mission Editor.

Thanks in advance to all!

#1
01/12/2007 (3:20 am)
I tried putting ToggleEditor(1); after the call to loadMyMission(); but no joy?

Help!
#2
01/12/2007 (5:43 am)
I got one of a few different solutions you could try Greg:

Put this in your loadMyMission():
$bMissionEditMode = true;              [b]// You probably don't need this variable
                                       //but I use it for my CustomMissionEditor
[/b]

[b]   // This is for a missionList GUI I have, similar to starter.fps's joinServerGUI
   // If you already know which mission you are loading, you can just set %mission
   // to the filepath of the .mis file[/b]
   %id = qeMissionListCtrl.getSelectedId();
   %mission = getField(qeMissionListCtrl.getRowTextById(%id), 1);
   
   // Close the editor (JIC)
   if(!isObject(Editor))
      Editor.close();
         
   // Create the single player server to do editing
   createServer( "SinglePlayer", %mission);
   %conn = new GameConnection(ServerConnection);
   RootGroup.add(ServerConnection);
   %conn.setConnectArgs($pref::Player::Name);
   %conn.setJoinPassword($Client::Password);
   %conn.connectLocal();
   
   Editor::create();
   MissionCleanup.add(Editor);
   EditorGui.loadingMission = true;
   EditorGui.saveAs = true;
   Editor.open();

   $dropcameracount = 0;

I have this code set up for this scenario: You're at the MainMenu and you press the MissionEditor button. This takes you to a screen which allows you to select which mission to edit or choose a blank template. When you press start, the function containing the above code is called. The mission will load with the WorldEditor (or CustomMissionEditor in my case) already open.

Let me know if that works for you.
#3
01/12/2007 (11:29 am)
Thanks for your reply.

However it seems a bit long winded?

The code to load the mission editor via the F11 key, is simply ToggleEditor(1);

Is there just a simple command to call the Mission Editor once my mission has loaded?
#4
01/12/2007 (1:12 pm)
Ouch, long winded.....

Go to the definition of ToggleEditor and have a look at what it does. This works for me, and I consider it a small code block.

If you want a real cheap way out, you can just use schedule() to call the editor after the mission loads.

*EDIT* Keep in mind this chunk of code loads your mission and loads the WorldEditor, so you are getting 2 functions in that ....long winded..... code block =)
#5
01/12/2007 (1:58 pm)
OK, apologies!

I looked in the editor.cs and saw the code block, so your way is the same as GG's way, so it must be right! :-)

Thanks again for your time!

Greg