In-game cosole?

I’m thinking of allowing people to use an in-game console to change stuff like the FOV, max health, in-game time or just about anything. I’m wondering if using directEntry and passing the input to exec() is a good idea. I’m also wondering if its possible to access the console output and print them in the in-game console instead.

It’s feasible, but I don’t like this solution because:

  • the user must use Python (you could provide a simpler language)
  • security issues (you are exec()uting an arbitrary command)

You could check the string before exec()uting it , but the first problem still remains. I would prefer to write a simple parser (I think that the language should be very simple).

You can redirect the output and then print it.

Sure doesn’t sound like worth it.
Its not just wasting time writing a parser, youll need to make a dictionary or something to match all the functions with the functions of the scripting language and update it every time you add a new function, not to mention you’ll need to assign few hundred functions to begin with.

I think python is a pretty simple language already…

I do agree on the security issue. If there was a simple way to only allow to use certain modules, that would be great.

It’s actually pretty easy and feasible. Look at the developer console class in Naith.

What is easy and feasible? Using your own scripting language? Or just the console itself?

BTW,

from code import InteractiveInterpreter

I can’t find ‘code’ module.

It’s easy and feasible to have a Python interpreter in-game.

It’s in the standard Python library. To include it in a p3d file, specify -r morepy on the packp3d command-line.

Oh, didnt think of that.

Um, the code seems a bit confusing. It would be very nice if you could tell what this basically does. It might just be me, but the official python standard library reference explanations have always seemed very difficult to understand, for engrish users.