Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 30 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save JLChnToZ/5f4b1a3e81373b3b20330c6a89067f1b to your computer and use it in GitHub Desktop.
Save JLChnToZ/5f4b1a3e81373b3b20330c6a89067f1b to your computer and use it in GitHub Desktop.

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
  1. Before you start, ensure Node.js is installed.
  2. Navigate to www.asciimation.co.nz, the original home of that ASCII-Art Star Wars.
  3. Press F12 to open developer tools.
  4. 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();
  1. You will get a starwars.txt file downloaded, it is important to save as starwars.txt or the code mentioned next will not work, unless you changed it in that code too.
  2. 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));
  1. Save it as any file name, besides the starwars.txt. Recommend filename: starwars.js.
  2. Open the terminal (CMD/PowerShell in Windows, *sh in *nix OSes), cd to the directory you saved the starwars.txt and starwars.js (or any name you choosed) file.
  3. Run following code in your terminal, if your file isn't called starwars.js then replace the filename to yours:
$ node starwars.js
  1. Enjoy! Now it is completely offline!
@simonjuulsgaard
Copy link

Thank you, that's really cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment