mirror of
https://github.com/He4eT/cheap-glkote.git
synced 2026-05-05 00:47:28 +00:00
Move player.stdio
This commit is contained in:
parent
1a9bf1ad0d
commit
b9e4269aa4
4 changed files with 6 additions and 5 deletions
62
bin/player.stdio.js
Normal file
62
bin/player.stdio.js
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* @see: https://github.com/curiousdannii/emglken/blob/master/bin/emglken.js
|
||||
*/
|
||||
|
||||
const fs = require('fs')
|
||||
const minimist = require('minimist')
|
||||
|
||||
const CheapGlkOte = require('../src/')
|
||||
const { handlers } = require('./stdio')
|
||||
|
||||
const formats = [
|
||||
{
|
||||
id: 'bocfel',
|
||||
extensions: /z([3458]|blorb)$/,
|
||||
engine: 'bocfel.js',
|
||||
},
|
||||
{
|
||||
id: 'glulxe',
|
||||
extensions: /(gblorb|ulx)$/,
|
||||
engine: 'glulxe.js',
|
||||
},
|
||||
{
|
||||
id: 'git',
|
||||
extensions: /(gblorb|ulx)$/,
|
||||
engine: 'git.js',
|
||||
},
|
||||
{
|
||||
id: 'hugo',
|
||||
extensions: /hex$/,
|
||||
engine: 'hugo.js',
|
||||
},
|
||||
{
|
||||
id: 'tads',
|
||||
extensions: /(gam|t3)$/,
|
||||
engine: 'tads.js',
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
const argv = minimist(process.argv.slice(2))
|
||||
const storyfile = argv._[0]
|
||||
|
||||
const format = formats.find(x =>
|
||||
x.extensions.test(storyfile))
|
||||
|
||||
if (!format) {
|
||||
console.error('Unknown storyfile format.')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const { glkInterface, sendFn } = CheapGlkOte(handlers)
|
||||
handlers.setSend(sendFn)
|
||||
|
||||
const engine = require('emglken/src/' + format.engine)
|
||||
const vm = new engine()
|
||||
|
||||
vm.prepare(
|
||||
fs.readFileSync(storyfile),
|
||||
glkInterface)
|
||||
vm.start()
|
||||
Loading…
Add table
Add a link
Reference in a new issue