Narrat Game Engine Documentation

website·Indexed 33 days ago

https://docs.narrat.dev/

Documentation for Narrat, a game engine featuring a custom scripting language for branching dialogue, skill systems, and HUD stats. Includes guides on using commands for audio, text, and variable modification, as well as features like scenes, themes, item interaction, and mobile support.

Tokens
43.3K
Snippets
268
Records
356
Agent score
61%

What's inside Narrat

  1. Overview of Narrat game engine

    Narrat is a game engine specifically designed for narrative games. It is particularly well-suited for story-driven games featuring player choices and TTRPG (Tabletop Role-Playing Game) mechanics.
  2. Overview of narrat game project structure

    A narrat game is a folder containing two primary types of content: dialogue scripts (.narrat files) for the branching narrative and configuration files (.yaml files) for game data.

    Key directories include:

    • public/: Contains static assets (images, music) and config files. Assets here are referenced by their path relative to the public folder (e.g., public/img/bg.png is referenced as /img/bg.png).
    • src/: Contains the engine setup (TypeScript files) and the scripts subfolder where .narrat files are located.
  3. Overview of Narrat Steam Integration

    Narrat provides built-in Steamworks integration for games created with the Narrat 4.0.0 template. This integration supports the Steam Overlay, Steam Achievements, Steam Cloud Saves, Steam Input (gamepad support), and native Steam Deck support.
  4. Overview of Narrat Godot integration

    The Narrat Godot integration plugin allows developers to embed a Godot 4 (4.1+) game within a Narrat project. This setup enables a hybrid experience where the Narrat UI sits on top of a Godot game, allowing for complex 2D or 3D gameplay combined with Narrat's branching dialogue and choice systems. The integration is specifically designed for games built for web export.
  5. Overview of Narrat game engine capabilities

    Narrat is a domain-specific game engine designed specifically for creating narrative games, particularly those with TTRPG mechanics (such as skills and skill checks) and branching dialogue. It provides a scrolling dialogue panel and a viewport for visual screens. Key capabilities include:

    • Out-of-the-box narrative features requiring no additional coding.
    • Customization of features via YAML settings files.
    • UI styling via CSS (limited to style changes, not layout/content changes).
    • A flexible dialogue panel and viewport resolution configuration.
    • A 'sprites' system for dynamically creating text and images on screen.
    • A scripting language that allows complex logic for game behavior without requiring general programming knowledge.
  6. Overview of Narrat Themes

    Narrat themes are packages used with the NarratThemesPlugin to instantly change the look and layout of a game. Themes consist of a CSS stylesheet and a theme definition file. They allow developers to:

    • Load new CSS to change colors, layout, and visuals.
    • Override Narrat configuration values (e.g., dialog panel or viewport settings) on the fly.
    • Swap themes during gameplay to change the UI context (e.g., switching from a small bottom text box to a full-screen overlay).
  7. Overview of the Narrat game engine

    Narrat is a game engine specifically designed for creating narrative-driven games without the need for programming. It is not intended for action games or projects requiring extensive custom technical features.
  8. Configure src/index.ts for Narrat 4 and Steam support

    Update src/index.ts to support the new plugin architecture and localization. Copy src/constants.ts and src/steam-plugin.ts from the Narrat 4 template into your src folder. The updated startApp call now includes a localization object containing the language and resource strings.
    import 'narrat/dist/main.css';
    import './css/main.css';
    import { registerPlugin, startApp } from 'narrat';
    import scripts from './scripts';
    import config from './config';
    import { strings } from './strings/strings';
    import { DEBUG, USE_STEAM } from './constants';
    import { SteamPlugin } from './steam-plugin';
    
    window.addEventListener('load', () => {
      let steam: SteamPlugin | undefined;
      if (USE_STEAM) {
        steam = new SteamPlugin();
        registerPlugin(steam);
      }
      startApp({
        debug: DEBUG,
        logging: false,
        scripts,
        config,
        localization: {
          debug: DEBUG,
          lng: 'en',
          resources: {
            ...strings,
          },
        },
      });
    });
  9. Use Hot Module Reloading for narrat scripts

    The narrat development server supports hot reloading of scripts. When a .narrat file is saved, changes are picked up live without restarting the game. All labels within the edited file are updated; however, the changes will not take effect until the game jumps to a label that has been modified.
  10. Display the Achievements UI

    The achievements UI is integrated automatically. If any achievements are defined in the configuration, a dedicated achievements tab will automatically appear in the game menu.
  11. Extend Narrat engine functionality using the Plugin API

    The Narrat plugin API allows developers to extend the engine using native TypeScript code and custom Vue.js components. Key capabilities include:

    • Custom Data Stores: Create Pinia data stores that are serialized into game save files and accessible by the UI.
    • Custom UI Elements: Add new menu buttons or tabs that render Vue.js components.
    • Custom Commands: Implement new commands for the narrat scripting language using the same API as built-in commands.
    • Lifecycle Hooks: Execute custom logic during engine load, page load, game start, and other events.
    • Engine Access: Access built-in data stores to manipulate game data, as well as engine configuration and internal utilities.
  12. Use basic gamepad support in Narrat

    As of version 3.2.0, Narrat includes built-in basic gamepad support. This feature works out of the box and requires no additional configuration to enable.