Skip to content

Instantly share code, notes, and snippets.

@mrw34

mrw34/package.json

Created Dec 14, 2015
Embed
What would you like to do?
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