UNPKG

arx-level-generator

Version:
27 lines 786 B
import { Script } from '../Script.js'; export class ScriptSubroutine { name; command; invokeType; constructor(name, command, invokeType = 'gosub') { this.name = name; this.command = command; this.invokeType = invokeType; } toString() { const renderedScript = Script.handlerToString(this.command); if (renderedScript.trim() === '') { return ''; } return [`>>${this.name} {`, renderedScript, this.invokeType === 'gosub' ? ' return' : ' accept', '}'].join('\n'); } invoke() { if (this.invokeType === 'gosub') { return `gosub ${this.name}`; } else { return `goto ${this.name}`; } } } //# sourceMappingURL=ScriptSubroutine.js.map