Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing a dev console for my game. Currently I have a simple parser which is basically a regex which accepts words with dashes and dots (ie. list, 1.0, list -i) or simplistic arrays and maps (ie. [1,2,3], [x:1.0, y:2.0]). I plan on making an AST parser later on but for now this works well enough.

When these tokens get parsed first token in parsed line is the command token which is used to invoke a registered command. Commands are classes which implement a ConsoleCommand interface which looks like this (basic command pattern):

interface ConsoleCommand {
    val description: String
    val instructions: String
    fun execute(args: Array<Any>): String
}

This works, but I'm not quite satisfied since to actually register any console commands I must do so where I can access the entity. For example if I want to register the player as an interactable console command I must do so either in a custom system only created for the specific console command, or add console specific code into existing systems, basically polluting my codebase with console specific code.

My question here is what are alternative dev console implementations? Is there a way to implement a console which wouldn't affect the rest of the codebase?

I have an inkling of an idea where the console could be some sort of an observer and it itself would register onto entities and stuff, but I don't see a way of implementing that without having the entities implement some sort of special observable interface so that they can actually be observed, as well as the fact that observers usually don't manipulate the entities themselves....

share|improve this question
    
Do you ask about game in compiled languages or the ones interpreted/with IL? – wondra Aug 14 at 18:33
    
@wondra I'm not quite sure what IL interpreter is but I'm building my game in Kotlin which is a compiled language running on the JVM. I am however aware that dev consoles can be made with the same language as the rest of the game, or it can be made using scripting languages such as Lua, however I'm not yet aware of the benefits/flaws of the two approaches, nor am I aware as to how to even expose my whole engine to an outside scripting language (conceptually, not syntactically) – MrPlow Aug 14 at 20:02
    
I probably asked differently: does your language have reasonable reflection support? That is probably the biggest question before you even start. – wondra Aug 14 at 20:08
    
@wondra I'd say it does. It runs on the JVM and thus has the same level of reflection support as Java, which basically means that I can verify and compare types, get all methods and fields of a class, run and modify them, and probably a lot more. – MrPlow Aug 14 at 20:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.