Here is the JavaScript I used to make a bot for ninjanode.
-
Move forward every 3 seconds
clearInterval(moverId); moverId = setInterval(function() { ShipSocket.socket.emit('key', {c: "u", s: 1}); setTimeout(function() { ShipSocket.socket.emit('key', {c: "u", s: 0}) }, 500) }, 3000)
-
Rotate counterclockwise every 8 seconds
clearInterval(spinnerId); spinnerId = setInterval( function() { ShipSocket.socket.emit('key', {c: "l", s: 1}) setTimeout(function() { ShipSocket.socket.emit('key', {c: "l", s: 0}) }, 100) }, 8000)
-
Fire the primary weapon every 0.325 seconds. You should change the time value depending on the reload rate of your ship.
clearInterval(shooterId); shooterId = setInterval( function() { ShipSocket.socket.emit('key', {c: "f", s: 1}) ShipSocket.socket.emit('key', {c: "l", s: 0}) }, 325)
-
Place a mine (secondary weapon) every 5 seconds. 5 seconds is the fastest that a mine can be placed.
clearInterval(minerId); minerId = setInterval( function() { ShipSocket.socket.emit('key', {c: "s", s: 1}) }, 5000)
To start any of these paste them into the JavaScript console in your web browser for ninjanode.
To stop any of these run clearInterval(spinnerId)
replacing spinnerId
with the
id of the bot you want to stop.