7
How to play ASCII-Art Star Wars offline
source link: https://gist.github.com/JLChnToZ/5f4b1a3e81373b3b20330c6a89067f1b
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to play ASCII-Art Star Wars offline
Following will teach you how to play the "easter-egg" (which actually isn't, but many people describe this as an easter egg) of ASCII-Art Star Wars (or Star Wars in terminal/telnet, whatever), the one you normally starts like this:
$ telnet towel.blinkenlights.nl
- Before you start, ensure Node.js is installed.
- Navigate to www.asciimation.co.nz, the original home of that ASCII-Art Star Wars.
- Press F12 to open developer tools.
- In the console, paste these code and press Enter:
var temp = document.createElement('a');
temp.href = URL.createObjectURL(new Blob([film.join('\n')], { type: 'text/plain' }));
temp.download = 'starwars.txt';
temp.click();
- You will get a
starwars.txt
file downloaded, it is important to save asstarwars.txt
or the code mentioned next will not work, unless you changed it in that code too. - Open any text editor you like, paste these code:
const { join } = require('path');
const { readFile } = require('fs');
const { promisify } = require('util');
const readFileAsync = promisify(readFile);
const delay = promisify(setTimeout);
(async() => {
const LINES_PER_FRAME = 14;
const DELAY = 67;
const filmData = (await readFileAsync(join(__dirname, 'starwars.txt'), 'utf8')).split('\n');
console.error('\n'.repeat(LINES_PER_FRAME));
for(let i = 0; i < filmData.length; i += LINES_PER_FRAME) {
console.error(`\x1b[${LINES_PER_FRAME}A\x1b[J${filmData.slice(i + 1, i + LINES_PER_FRAME).join('\n')}`);
await delay(parseInt(filmData[i], 10) * DELAY);
}
})().catch(e => console.error(e.stack || e));
- Save it as any file name, besides the
starwars.txt
. Recommend filename:starwars.js
. - Open the terminal (CMD/PowerShell in Windows, *sh in *nix OSes),
cd
to the directory you saved thestarwars.txt
andstarwars.js
(or any name you choosed) file. - Run following code in your terminal, if your file isn't called
starwars.js
then replace the filename to yours:
$ node starwars.js
- Enjoy! Now it is completely offline!
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK