Game Development Community

Console commands

by Travis Vroman · in General Discussion · 12/21/2003 (9:21 pm) · 1 replies

I was thinking today about how complicated the console is for TGE. How would we go about programming the console to accept commands in a different format? (For Example: /fps 1 or fps/0 to display the fps on the hud). I'm sure there must be a way to do this, right?

-Barzahd

#1
12/21/2003 (9:32 pm)
Um... I'm missing part of something here. The "Why" portion that provides a compelling reason why such a large change would be made. To me, the console isn't complicated at all. And the available console commands are fairly well documented if you look for 'em. (That wasn't always the case though.) Having said that...

If you are refering to the commands that are executed when you hit "~" and type in a command like showFPS(); - well, you could redo that yourself if you wanted to. Here's a hacky way to do it:

Go into the GUI editor, and edit the console's GUI. The textEdit line triggers an eval() on the text that you type in when you press enter. INstead, set up your own custom function like

function specialEval(%evalText)
{
Then, you could just set up a list of commands that are accessable (note - written off the top of my head, so, while it's logically correct, might need a few syntax tweaks here and there):
%usedCommand = 0;
   %commandHolder = strlwr(getword(%evalText, 0));
   switch$(%commandHolder)
   {
       case:  "fps"
           %subCommand = getWord(%evalText, 1)
           %usedCommand = 1;
           if(%subCommand == 1)
               fpsDisplayOn();
           if(%subCommand == 0)
               fpsDisplayOff();
       case:  "somethingelse"
           ...................
   }
   if(%usedCommand == 0)
       eval(%evalText);
}

There you go. You've now got a way to intercept the normal functionality of the console - it will evaluate your custom commands that you create first, but if nothing matches up, it will go ahead and eval() the text in the normal way. And this way, you don't break any compatibility with anything else :-)