Game Development Community

Detecting the mission editor?

by Dusty Monk · in Torque Game Engine Advanced · 08/06/2009 (10:10 am) · 3 replies

Is there an easy way to detect (in script) if the mission editor is active? An "$IsInEditorMode" global or some such? I've searched, but to no avail. I have a bunch of AI scripts I'd like to quickly and quietly die the moment I bring up the editor.

thanks in advance,

Dusty Monk
Windstorm Studios

About the author

Dusty Monk is founder and president of Windstorm Studios, an independant game studio. Formerly a sr. programmer at Ensemble Studios, Dusty has worked on AAA titles such as Age of Empires II & III, and Halo Wars.


#1
08/06/2009 (10:58 am)
C++: gEditingMission

TorqueScript: none that I know of, although you could easily add one, probably the best place is the function toggleEditor(). That, or you could expose the C++ variable.
#2
08/06/2009 (11:24 am)
Like Novak said, you could easily add a script function like:

function isEditorOpen()
{
   // Check if World Editor is open
   if(Canvas.getContent() == EditorGui.getId())
      return true;

   // Check if Gui Editor is open
   if(Canvas.getContent() == GuiEditorGui.getId())
      return true;

   // No editor was open
   return false;
}
#3
08/06/2009 (11:31 am)
Thanks! Yeah I dug into the function calls for toggleEditor and Editor.open, and the function that Ryan wrote is pretty much exactly what I created.

Of course, nothing is ever as easy as it seems. The canvas and the editor are all on the client side, and the scripts are on the server side, so what I ended up doing was when the editor is opened, it sends a command to the server to terminate the AI's, which in turns runs through all of AI scripts and executes a terminate command on them. So in a multi-user situation, if any client opens the editor, the plug is pulled on the AI's for all of them.

Pretty useful actually. Who wants mobs hacking at my player while I'm trying to get this tree rotated just right..