Created
December 14, 2015 20:06
-
-
Save mrw34/bfa3c1033c3c7adc8ded to your computer and use it in GitHub Desktop.
West London Xmas Hack Night
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"underscore": "^1.8.3", | |
"vorpal": "^1.4.0", | |
"ws": "^0.8.1" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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