Monogatari Documentation
HomepageGitHubDiscordTwitter
master
master
  • Welcome
  • Getting Started
    • Step 1: Setup Your Environment
    • Step 2: Download Monogatari
    • Step 3: Get Familiarized
    • Step 4: Make Your First Visual Novel
  • Upgrading from v1.4.1
  • F.A.Q.
  • Diagnosing Errors
  • Building Blocks
    • Script & Labels
    • Characters
    • Variables & Data Storage
    • Actions
      • Life Cycle
    • Components
      • Life Cycle
      • Built-in Properties
      • Built-in Functions
  • Script Actions
    • Choices
    • Clear
    • Conditionals
    • Dialogs
    • End
    • Gallery
    • Hide Canvas
    • Hide Character
    • Hide Image
    • Hide Particles
    • Hide Video
    • Input
    • Functions
    • Jump
    • Next
    • Placeholder
    • Play Music
    • Play Sound
    • Play Voice
    • Show Canvas
    • Show Background
    • Show Character
    • Show Image
    • Show Message
    • Show Notification
    • Show Particles
    • Show Scene
    • Show Video
    • Stop Music
    • Stop Sound
    • Stop Voice
    • Vibrate
    • Wait
  • Components
    • Credits Screen
    • Quick Menu
    • Loading Screen
    • Main Screen
    • Choice Container
    • Save Slot
    • Text-Box
  • Configuration Options
    • Game Configuration
      • Asset Preloading
      • Internationalization
      • Saving
      • Skip Main Menu
      • Storage
    • Player Preferences
    • Split Files
  • Style & Design
    • Responsiveness
    • CSS Classes
    • HTML Data Attributes
    • Icons
    • Image Menus
  • Releasing Your Game
    • Chrome App
    • Desktop App
    • Mobile
    • Web
  • Advanced: Monogatari Development
    • Core Libraries
      • Artemis
      • Kayros
      • Pandora
    • Actions
    • Components
    • Translations
    • Events
  • Releases
    • v2.0.0.alpha.8
    • v2.0.0.alpha.7
    • v2.0.0.alpha.6
    • v2.0.0.alpha.5
    • v2.0.0.alpha.4
    • v2.0.0.alpha.3
Powered by GitBook
On this page
  • Overview
  • Script
  • Labels
  • Jumping between labels
  • Translating your Script
  • Splitting your script in multiple files

Was this helpful?

  1. Building Blocks

Script & Labels

PreviousDiagnosing ErrorsNextCharacters

Last updated 4 years ago

Was this helpful?

Overview

The script is the soul and body of your game, it is the place where you define everything that happens on it. It is made out of labels that are just like the chapters of a book and inside of each label, you have a list of statements that will be run one by one as your story unfolds.

Script

A monogatari script is nothing more than a . In simple terms, a JSON object is defined with two curly braces {}. Inside these curly braces, you can have a list of named properties that point to a value. For example, if we wanted to define a person using the JSON notation, we could do something like this:

const person = {
    'name': 'Jane Doe',
    'age': 24
};

This is what we call key/value pairs, where a key like name or age points to a value like Jane Doe or 24. Notice how each key/value pair has a comma in the end separating it from the next one. Missing commas is the #1 issue that people have on their scripts.

In Monogatari's case, your script is a list of keys (the names of the on your game) and values (the list of statements these labels are made of). For example:

{
    'Start': [
        'Hi there!',
        'This is a list of statements',
        'jump myLabel'
    ],
    'myLabel': [
        'And this is yet another label',
        'Also a list of statements',
        'end'
    ]
}

Now, while that object does defines a monogatari script, just by itself it doesn't do anything. You must use the script function to let monogatari know what's your script:

monogatari.script ({
    'Start': [
        'Hi there!',
        'This is a list of statements',
        'jump myLabel'
    ],
    'myLabel': [
        'And this is yet another label',
        'Also a list of statements',
        'end'
    ]
});

By default, the script.js file contains the initial script for any monogatari game and you can build your game from there by adding more content and removing the old one.

Labels

Let's take a look at an incredibly simple script, this is the most basic script a game could have:

monogatari.script ({
    'Start': [
        'This is a statement.',
        'end'
    ]
});

Notice that Start string. By default, Start is the first label that Monogatari will play when a game starts. As you can see, this label is pointing to a list of statements that monogatari will run one by one.

In programming terms, a label is

As we said before, labels are just like the chapters of a book but can also provide you with logical ways of dividing your game.

Jumping between labels

monogatari.script ({
    'Start':[
        'This is a statement.',
        'jump mylabel'
    ],
    'mylabel':[
        'This is another statement.',
        'Pretty easy huh?',
        'end'
    ]
});

As you can see from this script, we have two labels, Start and mylabel. Players will start in the Start one by default which will print out the first dialog and when the player clicks to advance, it will reach the jump mylabel statement. When reached, the game will simply carry on with the statements inside the mylabel label without the player ever noticing something happened.

Translating your Script

Making your game available in many languages is super simple, head over to the Internationalization guide to learn more.

Splitting your script in multiple files

As your game script grows, having it all in the same file might become troublesome. Splitting your script into multiple files is a good way to get organized and make it less cluttered. Learn how to do this in the Split files section.

As books can have many chapters, you can have many labels as well! Not only that, you can make your game move from one label to another using the .

Jump action
Split Files
JSON object
labels