That kind of depends on how your game is set up. If you specifically want to use the console then perhaps you could keep a separate thread running waiting for input from console.
I want it through a command line I will program into my game. No need for separate threads because I cannot give them arguments besides a void pointer.
So you bind a key to open the console and redirect keyboard input to the console. When the enter key is pressed parse whatever has been input and call the correct corresponding functions. Easier said then done, but what part are you having trouble with?
If I understand your minecraft idea then all you do is have the first word be the function that the user will type and the following words are its parameters. For example:
/set time <interger that represents time>
the set is a function you define that two arguments: a variable that can be set by the user (in this case time) and a value that it can be set to (in this case an integer). You could make use of the stringstream class to help you.
Well how you would bring up a text box will depend on what lib you are using. If you can get a text box, then you just pass the text once the user presses Enter. You then parse the text as I explained above, and you code the methods.
Reading in text is trivial; you have something visible, where the user can type. The hard part is the parsing of that input. That is why many use python or other library, which do most of the boiler plate stuff for you.
1) I suggest to look at command string as at nested commands.
1 2 3 4 5
set time 0
^ ^ ^
| | subcommand parameter
| subcommand (or command argument)
command
So you could do something like:
1 2 3 4 5 6 7 8 9 10 11 12 13
//Command processer: bool operator()(istream& input)
std::string command, argument;
input >> command;
std::getline(input, argument);
//std::unordered_map<std::string, std::function<bool (std::istream&)>> commands;
if (commands.find(command) == commands.end())
console::output << "cannot find command " << command;
else
commands[command](std::istringstream(argument););
//...
//time command function inherited from command processor
//Leaf node (time_set) will overload operator() or just be another function or functor not inherited from anything.
Wrong attitude. You make it ("have to") sound so negative. It should be positive: "Maps! Something new and exciting!. Cool! Why haven't I studied those yet? Hmm, what else might I learn while I'm at it?"
15 mobs, "spawn", "info", "killall", "disguise" commands each takes mob as an argument = 60 combinations. And there will be more as your program grows. Good luck with copy-pasting it. And you will know hat hell for programmers is like, when you need to change something significant.
Java is bad choice for perfomance-critical (read: with good graphics/complex calculations) games.
Minecraft compiled in native code with Excelsior JET works WAY faster than in Java enviroment (Up to 30% fps increase and less lag when generating chunks)
I still didn't see things like Dwarf Fortress written in Java too. Just because Java is too slow for this.