📃
VeinIF documentation
  • Introduction
  • Perquisites
  • Features
  • Tutorial
    • Getting Started
    • Tutorial
    • Extending the framework
  • Components
    • Paragraph
    • Choice
  • Optional Components
    • Precondition
    • Consequence
  • Files
    • File Structures
    • Code snippets
  • Modifying Guide
    • Preface
    • HTML Layout
  • API
    • Formatting
      • capitalise
      • greyOut
    • ParagraphFunctions
      • getCurrentParagraphName
  • Change log
    • Change log
Powered by GitBook
On this page
  • Introduction
  • Example 1: Adding new property to the "Paragraphs" interface

Was this helpful?

  1. Tutorial

Extending the framework

Sometime you just need more.

PreviousTutorialNextParagraph

Last updated 4 years ago

Was this helpful?

Introduction

VeinIF provides the foundation to easily create choice-based Interactive Fiction games, but for specific features . In the case where creators wants

Can't find an example of what you're looking for? Please create a on our GitHub page and describe your request.

Example 1: Adding new property to the "Paragraphs" interface

Use case: suppose the programmer wants to add optional property "special" that will trigger a custom function.

First, create a new interface that extends the Paragraphs interface. The new interface will inherit all of Paragraphs 's property plus the addition of the special property.

interface ParagraphPlus extends Paragraphs {
  special?: string;
}

export function getParagraph(player?: Player) {
  let paragraphs: ParagraphPlus[] = [ ... ]

Next, navigate to src/core/paragraphsFunction.ts. In updateParagraph(), add the necessary function to handle your new property.

new issues