frontispiece / apps / example / commands / index.ts
index.ts
Raw
import { Command } from '@a-morphous/frontispiece-ink-processor/src/data/command'
import { CommandParams } from '@a-morphous/frontispiece-ink-processor/src/types'

export const Pause: Command =  (engine, params: CommandParams) => {
	const time: number = params.time as number ?? parseFloat(params._[0])
	if (time > 0) {
		engine.locked = true
		setTimeout(() => {
			engine.locked = false
			engine.advance()
		}, time * 1000)
	}
	return {
		interruptStoryFlow: true
	}
}

export const Log: Command = (engine, params: CommandParams) => {
	console.log(params._.join(' '))
	return undefined
}

export const Clear: Command = (engine, params) => {
	engine.hideAllVisible()
	return undefined
}

export const AddRandomLine: Command = (engine, params) => {
	engine.insertLines(["Hello world", "You can add random extra lines"])
	return undefined
}