Skip to content

Instantly share code, notes, and snippets.

@mrw34
Created December 14, 2015 20:06
Show Gist options
  • Save mrw34/bfa3c1033c3c7adc8ded to your computer and use it in GitHub Desktop.
Save mrw34/bfa3c1033c3c7adc8ded to your computer and use it in GitHub Desktop.
West London Xmas Hack Night
{
"dependencies": {
"underscore": "^1.8.3",
"vorpal": "^1.4.0",
"ws": "^0.8.1"
}
}
var WebSocket = require('ws');
var _ = require('underscore');
var vorpal = require('vorpal')();
var ws = new WebSocket('ws://10.112.155.244:8080');
_.forEach({l: 'Look', b: 'DropBomb', n: 'MoveNorth', e: 'MoveEast', s: 'MoveSouth', w: 'MoveWest'}, function(command, shortcut) {
vorpal
.command(shortcut, command)
.action(function(args, callback) {
ws.send(JSON.stringify({command: command}));
callback();
});
});
ws.on('open', function open() {
ws.send(JSON.stringify({command: ['SetName', 'The Sprouts']}));
vorpal.delimiter('$').show();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment