I just managed to to get a Node.js minecraft bot API (called mineflayer) to work. When I was making minecraft bot the last time (in C++, all by myself), I had a problem that when writing in the console, the server messages would mix with whatever I'm writing. The answers I got back then seemed to have too complicated/unclear solutions so I gave up.
Now I was hoping that Node.js has this problem solved, but apparently not. Is there an easy solution in Node.js? What I want is this:
But now, commands that I'm writing mix with output (red is written input, green is console output, colored using GIMP):
I am using the readline
module for that:
var readline = require("readline");
var rl = readline.createInterface({
input: process.stdin,
output: null,
});
rl.on('line', function(line) {
var inp = line.trim();
//Bot internal commands start with ~
if(line[0]=='~') {
command(line.substr(1));
}
else {
//use server chat
bot.chat(line);
}
});