Best Practices

Best Practices

This page shows common patterns and examples for organizing your project. You're free to structure your stories however works best for you - these are just suggestions to consider.

Project Organization

Many developers find it helpful to organize their project as their story grows in complexity. Here are some common organizational patterns you might consider.

Folder Structure Example

You can organize your scripts and assets however you like. Here's one example of a folder hierarchy:

MyProject/
├── Content/
│   ├── Chapters/
│   │   ├── Chapter1/
│   │   │   ├── scene1.sfe
│   │   │   ├── scene2.sfe
│   │   │   └── scene3.sfe
│   │   ├── Chapter2/
│   │   │   └── ...
│   ├── Characters/
│   │   ├── player_dialogue.sfe
│   │   ├── npc1_dialogue.sfe
│   │   └── npc2_dialogue.sfe
│   ├── Systems/
│   │   ├── inventory.sfe
│   │   ├── combat.sfe
│   │   └── quests.sfe
│   ├── Images/
│   │   ├── backgrounds/
│   │   ├── characters/
│   │   └── ui/
│   └── global-variables.json
└── MyProject.storyflow

Naming Examples

You can name your files and variables however you prefer. Here are some common patterns:

Startup Script

Some developers create a dedicated startup script that:

Tip

Name your startup script something obvious like main_menu.sfe or start.sfe. Set it as your project's startup script in the project settings.

Node Graph Structure

Well-structured node graphs are easier to understand, debug, and maintain.

Visual Layout Examples

Modularity with Run Script Nodes

You can break large stories into smaller, reusable scripts. Here are some common approaches:

Example: Shop System

Instead of copying shop dialogue to every merchant, create shop_system.sfe and call it with Run Script nodes. Use global variables to track inventory and gold across all merchants.

Connection Patterns

Variable Management

Proper variable usage is key to creating complex, stateful narratives.

Local vs Global Variables

You can choose the scope for your variables based on how long the data needs to persist:

Local Variables

Global Variables

Variable Naming Examples

State Management Examples

Variable Limits

While there's no hard limit on variables, using hundreds of variables can make your project harder to manage. Group related state and reuse variables when possible.

Performance Optimization

Keep your stories running smoothly with these optimization techniques.

Node Graph Efficiency Examples

Asset Management Examples

Export Optimization Examples

Testing & Debugging

Regular testing helps catch bugs early and ensures all story paths work correctly.

Using the Play Feature

Common Issues and Solutions

Dialogue option doesn't work

Check that the option has an outgoing connection with the correct source handle. Each dialogue option needs a connection from its specific handle to the next node.

Branch always takes same path

Verify the boolean input is connected and the variable is set correctly. Use the Runtime Debugger to check variable values in real-time.

Script doesn't load

Ensure the script file exists in the Content folder and has a .sfe extension. Check for typos in the script path configured in Run Script nodes.

Variables not changing

Check that Set Boolean and Set Integer nodes are connected to execution flow (primary handle), not just data flow (secondary handle).

Circular dependency error

Remove scripts calling themselves directly or indirectly more than 20 levels deep. Refactor your script structure to avoid infinite loops and use End nodes to properly terminate execution.

Debugging Workflow

  1. Identify the Problem: Note exactly when and where the issue occurs
  2. Check Connections: Verify all edges are connected to the correct handles
  3. Trace Execution Flow: Follow the node path from Start to the problem point
  4. Inspect Variables: Check if variables have expected values
  5. Simplify: Temporarily remove complex logic to isolate the issue
  6. Test Incrementally: Add back complexity piece by piece, testing after each change

Debugging Tip

Add comment nodes to mark potential problem areas. During testing, you can use dialogue nodes with debug messages like "DEBUG: Player health is [value]" to track state.

Version Control

Protect your work and enable collaboration with version control best practices.

Using Git

StoryFlow Editor projects work well with Git version control. Here are some common patterns:

Backup Examples

Collaboration Examples

Common Pitfalls

Avoid these common mistakes when building interactive stories.

Story Structure Issues

Variable Mistakes

Logic Errors

Performance Problems

Still Stuck?

If you're experiencing issues not covered here, join our Discord community for help from the team and other users. Be sure to describe your issue in detail and share screenshots if possible!

→ Your First Project→ Variables→ Content Browser→ Play in Editor

← Previous: Game Engine Integration

Need Help?