Page 1 of 1

how to create in-game console like in Quake?

Posted: Tue Nov 07, 2006 12:07 pm
by sandfighter
anyone knows how to start writing my own in-game console? i've tried to build it with the irrlicht interface but it won't work... i only know that a console need something called "parsing language". can you provide me with some external links? or please just tell me how to start thinking about console in my game... :?

Posted: Tue Nov 07, 2006 1:22 pm
by Lideln
Hi !

Im not an experienced coder, but if you want some general ideas to follow, here is what I can tell you

Graphically, for the console, you will have one Image, with 2 textbox children.
One will be used to enter the text, the other, multiline, will show the log.

Write an key event handler for the input textfield, and associate the keys you need (UP and DOWN for going through commands "history", ENTER to validate and parse the command, etc.)

To parse the command, you can write a real parser ONLY if you will have complex commands (it cant be explained in 2 lines, you have to search for websites explaining it... In general, you have to use the lex language, and then call your parser from your code).
The other option is to simply parse the command with the C function strtok (look at google to see how it works), and when you have your different tokens (a token is generally a word or an operator), you can call this one or that other function depending on the tokens.

You can also use function pointers.

Make some tests and you'll find the good way by yourself :)

Hope this helps,

Lideln

Posted: Tue Nov 07, 2006 1:45 pm
by bitplane
a few people have already made these, there's one by rambus in the code snippets forum, there's acki's chat box (which is a good start for someone making their own), and there's at least one more I remember seeing somewhere (as part of irrwizard perhaps?) try searching the forums
as for a console language, you'll want some script integration. there are a few different scripting language implementations knocking around the forums too

Posted: Tue Nov 07, 2006 1:46 pm
by vitek
I would not immediately suggest writing your own parser. It may be much more effective to integrate a scripting engine like gamemonkey, squirrel, python or lua.

Travis

Posted: Tue Nov 07, 2006 2:00 pm
by jam
To add to bitplane's list, mohaps had one called IrrConsole if I remember correctly.

Posted: Tue Nov 07, 2006 6:10 pm
by bitplane
thinking of having a console in the first place, i spose it's only of any real use if you already have some kind of scripting.
I mean... it's supposed to be a useful debug interface to your scripting engine isn't it?

Posted: Wed Nov 08, 2006 3:42 pm
by sandfighter
well... i have already started writing my own FPS, but i need some useful tool to check what can be done in Irrlicht from user interface. a command line is something very helpful. for example if you want to test connection between two computers in your game, just open a console window and type eg.: "connect ip.of.your.friend" and that's the simplest way.

by the way, thank's for all help :)