Game Development Community

A short story about $runWithEditors ...

by Tom Bampton · in Torque Game Builder · 11/22/2005 (1:50 am) · 3 replies

So, I was hacking away at a game and I had to edit main.cs for some reason, and I glanced upon $runWithEditors once more ... and thought ... goddamn, that's lame ...

So, I opened up consoleFunctions.cc and scanned it for an isDirectory() console function ... of which there was none. So I added this, just after isFile() ...

ConsoleFunction(isDirectory, bool, 2, 2, "isDirectory(fileName)")
{
   argc;
   Con::expandScriptFilename(scriptFilenameBuffer, sizeof(scriptFilenameBuffer), argv[1]);
   return Platform::isDirectory(scriptFilenameBuffer);
}

Then I went back to our pre-historic friend main.cs, and hacked it so it looked like this: click here for new main.cs

And now, if the editors are there, it loads them. If they're not, it doesnt. All you have to worry about now is making sure the editors dont end up in a public build.

Some quick info on the new stuff in main.cs ...

Mod/editor info is now set at the top of the file (as in TGE), rather then somewhere in the middle that's annoying to find.

You set $defaultGame and $userMods as before. For example:

$modcount = 1;
$defaultGame = "uc";
$userMods = $defaultGame;

Then you set $dndMods to whatever mods that you only want loaded if they exist ...

$dndMods = "creator;tileeditor;particleeditor";

Note: my copy of T2D runs in 1.4, if you're using stock T2D then you'll need to remove creator ... or rather, no you dont, since it wont exist and thus it wont get loaded! muwahaha!

T.

#1
11/22/2005 (4:17 am)
Tom,

Yeah, this was all temporary anyhow. There's a packaging utility for releases so it won't matter anyhow. Anything that makes it easier in the meantime though is always handy. :)

Bug?

- Melv.
#2
11/22/2005 (4:19 am)
Melv,

With this, the packaging utility has to do less work ;-)

I dont really know why i posted in the bugs forum. I'll put that one down to early morning inebriation.

T.
#3
11/22/2005 (11:36 am)
Don't worry man; I think I put that awful "$runWidthEditors" option in for the same reason. :)

The existing structure is going to be refined to make it easier for new people to get to grips with anyway.

- Melv.