Files
talemate/docs/user-guide/howto/infinity-quest-dynamic/2-initial-nodes.md
veguAI 89d16ae513 0.33.0 (#229)
* linting

* Add cleanup function for recent scenes in config to remove non-existent paths

* remove leghacy world state manager buttons

* move world state scene tools into sub component

* linting

* move module properties to navigation drawer

* Update icons in NodeEditorLibrary and NodeEditorModuleProperties for improved UI clarity

* prompt tweaks

* director chat prompt simplifications

* more prompt fixes

* Enhance type hints for duration conversion functions in time.py

* narrate time action now has access to response length instructions

* Add IsoDateDuration node for ISO 8601 interval string construction

* Update advance_time method to include return type annotation and return message

* Add AdvanceTime node to world state for time advancement with duration and narration instructions

* linting

* Add agent state exclusions to changelog with a TODO for module migration

* Add message emission for actor, narrator, and scene analysis guidance in respective components. Enhance AgentMessages and SceneTools for better message handling and visual feedback.

* Remove agent messages from state when opening agent message view in SceneTools component.

* linting

* openroute fetch models on key set

* Add input history functionality to message input in TalemateApp component. Implement keyboard shortcuts for navigating history (Ctrl+Up/Down) and limit history to the last 10 messages. Update message sending logic to store messages in history.

* Update message input hint in TalemateApp component to include keyboard shortcuts for navigating input history (Ctrl+Up/Down).

* node updates

* unified data extraction function

* prompt tweaks

* Add gamestate context support in BuildPrompt and corresponding template. Introduced new property for gamestate context and updated rendering logic to include gamestate information in prompts.

* Refactor Prompt class by removing LoopedPrompt and cleaning up related methods. Update data response parsing to streamline functionality and improve clarity. Adjust imports accordingly.

* Add 'data_multiple' property to GenerateResponse class to allow multiple data structures in responses. Update output socket type for 'data_obj' to support both dict and list formats.

* Add DictUpdate node

* Add UnpackGameState node to retrieve and unpack game state variables

* gamestate nodes

* linting

* Enhance scene view toggle functionality to support shift-click behavior for closing all drawers when hiding the scene view.

* immutable scenes should reset context db on load

* linting

* node updates

* prompt tweaks

* Add context type output and filtering for creative context ID meta entries in PathToContextID and ContextIDMetaEntries nodes

* Add string replacement functionality and Jinja2 formatting support in nodes. Introduced 'old' and 'new' properties for substring replacement in the Replace node, and added a new Jinja2Format node for template rendering using jinja2.

* Add additional outputs for context validation in ValidateContextIDItem node, including context type, context value, and name.

* prompt tweaks

* node adjustments

* linting

* Add data_expected attribute to Focal and Prompt classes for enhanced response handling

* node updates

* node updates

* node updates

* prompt tweaks

* director summary return appropriately on no action taken

* Enhance action handling in DirectorChatMixin by skipping actions when a question is present in the parsed response, ensuring better response accuracy.

* Enhance ConfirmActionPrompt component by adding anchorTop prop for dynamic alignment and adjusting icon size and color for improved UI consistency.

* anchor clear chat confirm to top

* responsive layout fixes in template editors

* linting

* relock

* Add scene progression guidance to chat-common-tasks template

* Refactor push_history method to be asynchronous across multiple agents and scenes, ensuring consistent handling of message history updates.

* Update chat instructions to clarify user intent considerations and enhance decisiveness in responses. Added guidance on distinguishing between scene progression and background changes, and refined analysis requirements for user interactions.

* Enhance DirectorConsoleChatsToolbar by adding a usage cheat sheet tooltip for user guidance and refining the Clear Chat button's UI for better accessibility.

* store character data at unified point

* fix button

* fix world editor auto sync

* Shared context 2 (#19)

Shared context

* Refactor NodeEditorLibrary to improve search functionality and debounce input handling. Updated v-text-field model and added a watcher for search input to enhance performance.

* Refactor NodeEditor and TalemateApp components to enhance UI interactions. Removed the exit creative mode button from NodeEditor and updated tooltips for clarity. Adjusted app bar navigation icons for better accessibility and added functionality to switch between node editor and creative mode.

* comment

* Character.update deserialize voice value correctly

* Enhance SharedContext.update_to_scene method to properly add or update character data in the scene based on existence checks. This improves the synchronization of character states between shared context and scene.

* shared context static history support
fix context memory db imports to always import

* Update WorldStateManagerSceneSharedContext.vue to clarify sharing of character, world entries, and history across connected scenes.

* linting

* Enhance chat modes by adding 'nospoilers' option to DirectorChat and related payloads. Update chat instructions to reflect new mode behavior and improve UI to support mode-specific icons and colors in the DirectorConsoleChatsToolbar.

* Comment out 'repetition_penalty_range' in TabbyAPIClient to prevent unexpected "<unk><unk> .." responses. Further investigation needed.

* linting

* Add active_characters and intro_instructions to Inheritance model; implement intro generation in load_scene_from_data. Update WorldStateManagerSceneSharedContext.vue to enhance new scene creation dialog with character selection and premise instructions.

* rename inheritance to scene initialization

* linting

* Update WorldStateManagerSceneSharedContext.vue to conditionally display alert based on scene saving status and new scene creation state.

* Refine messages for shared context checkboxes in WorldStateManagerCharacter and WorldStateManagerWorldEntries components for clarity.

* Add scene title generation to load process and update contextual generation template. Introduced a new method in AssistantMixin for generating scene titles, ensuring titles are concise and free of special characters. Updated load_scene_from_data to assign generated titles to scenes.

* linting

* Refactor GameState component to integrate Codemirror for JSON editing, replacing the previous treeview structure. Implement validation for JSON input and enhance error handling. Remove unused methods and streamline state management.

* Add lastLoadedJSON property to GameState component for change detection. Update validation logic to prevent unnecessary updates when game state has not changed.

* Remove status emission for gameplay switch in CmdSetEnvironmentToScene class.

* allow individual sharing of attributes and details

* linting

* Remove redundant question handling logic in DirectorChatMixin to streamline action selection process.

* Update EXTERNAL_DESCRIPTION in TabbyAPI client to include notes on EXL3 model sensitivity to inference parameters. Adjust handling of 'repetition_penalty_range' in parameter list for clarity.

* director chat support remove message and regenerate message

* Refactor ConfirmActionInline component to improve button rendering logic. Introduced 'size' prop for button customization and added 'comfortable' density option. Simplified icon handling with computed property for better clarity.

* linting

* node updates

* Add appBusy prop to DirectorConsoleChats and DirectorConsoleChatsToolbar components to manage button states during busy operations.

* Refactor DirectorChatMixin to utilize standalone utility functions for parsing response sections and extracting action blocks. This improves code clarity and maintainability. Added tests for new utility functions in test_utils_prompt.py to ensure correct functionality.

* Update clear chat button logic to consider appBusy state in DirectorConsoleChatsToolbar component, enhancing user experience during busy operations.

* linting

* Remove plan.md

* Add chat template identifier support and error handling in ModelPrompt class

- Implemented logic to check for 'chat_template.jinja2' in Hugging Face repository.
- Added new template identifiers: GraniteIdentifier and GLMIdentifier.
- Enhanced error handling to avoid logging 404 errors for missing templates.
- Introduced Granite.jinja2 template file for prompt structure.

* node fixes

* remove debug msg

* Enhance error handling in DynamicInstruction class by enforcing header requirement and ensuring content defaults to an empty string if not provided.

* recet scene message visibility on scene load

* prompt tweaks

* Enhance data extraction in Focal class by adding a fallback mechanism. Implemented additional error handling to attempt data extraction from a fenced block if the initial extraction fails, improving robustness in handling responses.

* linting

* node fixes

* Add relative_to_root function for path resolution and update node export logic

- Introduced a new function `relative_to_root` in path.py to resolve paths relative to the TALEMATE_ROOT.
- Updated the `export_node_definitions` function in registry.py to use `relative_to_root` for module path resolution.
- Added a check to skip non-selectable node definitions in litegraphUtils.js during registration.

* show icons

* Improve error handling in export_node_definitions by adding a try-except block for module path resolution. Log a warning if the relative path conversion fails.

* typo

* Refactor base_attributes type in Character model to a more generic dict type for improved flexibility

* relock

* ensure character gets added to character_data

* prompt tweaks

* linting

* properly activate characters

* activate needs to happen explicitly now and deactivated is the default

* missing arg

* avoid changed size error

* Refactor character removal logic in shared context to prevent deletion; characters are now only marked as non-shared.

* Add update_from_scene method calls in SharedContextMixin for scene synchronization

* Add ensure_changelogs_for_all_scenes function to manage changelog files for all scenes; integrate it into the server run process.

* Enhance backup restore functionality by adding base and latest snapshot options; improve UI with clearer labels and alerts for restore actions.

* Update _apply_delta function to enhance delta application handling by adding parameters for error logging and force application of changes on non-existent paths.

* Skip processing of changelog files in _list_files_and_directories function to prevent unnecessary inclusion in file listings.

* Update IntroRecentScenes.vue to use optional chaining for selectedScene properties and enhance backup timestamp display with revision info.

* linting

* Refactor source entry attribute access in collect_source_entries function to use getattr for optional attributes, improving robustness.

* Implement logic to always show scene view in scene mode within TalemateApp.vue, enhancing user experience during scene interactions.

* prompt tweaks

* prompt tweaks

* Update TalemateApp.vue to set the active tab to 'main' when switching to the node editor, improving navigation consistency.

* Add active frontend websocket handler management in websocket_endpoint

* agent websocket handler node support

* Refactor init_nodes method in DirectorAgent to call superclass method and rename chat initialization method in DirectorChatMixin for clarity.

* Add characters output to ContextHistory node to track active participants in the scene

* Add Agent Websocket Handler option to Node Editor Library with corresponding icons and labels

* Add check for node selectability in NodeEditorNodeSearch component to filter search results accordingly.

* Add SummarizeWebsocketHandler to handle summarize actions and integrate it into SummarizeAgent

* nodes

* Add data property to QueueResponse class for websocket communication and update run method to include action and data in output values.

* Update manual context handling in WorldStateManager to include shared property from existing context

* Enhance GetWorldEntry node to include 'shared' property in output values from world entry context

* Update scene loading to allow setting scene ID from data and include ID in scene serialization

* Update icon for AgentWebsocketHandler in NodeEditorLibrary component to mdi-web-box

* Refactor WorldStateManager components to enhance history management and sharing capabilities. Added summarized history titles, improved UI for sharing static history, and integrated scene summarization functionality. Removed deprecated methods related to shared context settings.

* linting

* Change log level from warning to debug for migrate_narrator_source_to_meta error handling in NarratorMessage class.

* Update GLM-no-reasoning template to include <think></think> tag before coercion message for improved prompt structure.

* allow prompt templates to specify reasoning pattern

* Add Seed.jinja2 template for LLM prompts with reasoning patterns and user interaction handling

* Enhance NarratorAgent to support dynamic response length configuration. Updated max generation length from 192 to 256 tokens and introduced a new method to calculate response length. Modified narration methods to accept and utilize response length parameter. Added response length property in GenerateNarrationBase class and updated templates to include response length handling.

* Update response length calculation in RevisionMixin to include token count for improved text processing.

* Refactor response identifier in RevisionMixin to dynamically use calculated response length for improved prompt handling.

* linting

* allow contextual generation of static history entries

* Add is_static property to HistoryEntry for static history entry identification

* Add "static history" option to ContextualGenerate node for enhanced contextual generation capabilities.

* Add CreateStaticArchiveEntry and RemoveStaticArchiveEntry nodes for managing static history entries. Implement input/output properties and error handling for entry creation and deletion.

* nodes updated

* linting

* Add assets field to SceneInitialization model and update load_scene_from_data function to handle scene assets. Update WorldStateManagerSceneSharedContext.vue to include assets in scene initialization parameters.

* Refactor CoverImage component to enhance drag-and-drop functionality and improve styling for empty portrait state.

* Add intent_state to SceneInitialization model and update load_scene_from_data function to handle intent state. Introduce story_intent property in Scene class and reset method in SceneIntent class. Update WorldStateManagerSceneSharedContext.vue to include intent state in scene initialization parameters.

* Refactor WorldStateManagerSceneSharedContext.vue to improve cancel functionality by introducing a dedicated cancelCreate method and removing the direct dialog toggle from the Cancel button. This enhances code clarity and maintainability.

* Update SharedContext to use await for set_shared method, ensuring proper asynchronous handling when modifying character sharing status.

* Add MAX_CONTENT_WIDTH constant and update components to use it for consistent max width styling

* fix issue with data structure parsing

* linting

* fix tests

* nodes

* fix update_introduction

* Add building blocks template for story configuration and scene management

* Refactor toggleNavigation method to accept an 'open' parameter for direct control over drawer visibility in TalemateApp.vue

* Update usageCheatSheet text in DirectorConsoleChatsToolbar.vue for clarity and add pre-wrap styling to tooltip

* Add cover image and writing style sections to story and character templates; update chat common tasks with new scene restrictions and user guide reference.

* linting

* relock

* Add EmitWorldEditorSync node to handle world editor synchronization; update WorldStateManager to refresh active tab on sync action.

* Update Anthropic client with new models and adjust default settings; introduce limited parameter models for specific configurations.

* director action  module updates

* direct context update fn

* director action updates

* Update usageCheatSheet in DirectorConsoleChatsToolbar.vue to include recommendation for 100B+ models.

* Remove debug diagnostics from DirectorConsoleChats.vue to clean up console output.

* Update card styles in IntroRecentScenes.vue for improved visual consistency; change card color to grey-darken-3 and adjust text classes for titles and subtitles.

* Update EmitWorldEditorSync node to include websocket passthrough in sync action for improved event handling.

* Increase maximum changelog file size limit from 500KB to 1MB to accommodate larger change logs.

* linting

* director action module updates

* 0.33 added

* Add Nexus agent persona to talemate template and initialize phrases array

* Add support for project-specific grouping in NodeEditorLibrary for templates/modules, enhancing organization of node groups.

* docs

* Enhance NodeEditorLibrary by adding primary color to tree component for improved visibility and user experience.

* docs

* Enhance NewSceneSetupModal to include subtitles for writing styles and director personas, improving context and usability.

* Update agent persona description in WorldStateManagerTemplates to specify current support for director only, enhancing clarity for users.

* Refine agent persona description in WorldStateManagerTemplates to clarify assignment per agent in Scene Settings, maintaining focus on current director-only support.

* fix crash when attempting to delete some clients

* Add TODO comments in finalize_llama3 and finalize_YI methods to indicate removable cruft

* Add lock_template feature to Client configuration and update related components for template management

* linting

* persist client template lock through model changes

* There is no longer a point to enforcing creative mode when there are no characters

* fix direct_narrator character argument

* Update CharacterContextItem to allow 'value' to accept dict type in addition to existing types

* docs

* Update lock_template field in Client model to allow None type in addition to bool

* Remove unused template_file field from Defaults model in Client configuration

* Refactor lock_template field in Client model and ClientModal component to ensure consistent boolean handling

* Add field validator for lock_template in Client model to ensure boolean value is returned

* fix issue where valid data processed in extract_data_with_ai_fallback was not returned

* Update default_player_character assignment in ConfigPlugin to use GamePlayerCharacter schema for improved data validation

* linting

* add heiku 4.5 model and make default

* opse 4.5 isnt a thing

* fix issue where  fork / restore would restore duplicate messages

* improve autocomplete handling when prefill isn't available

* prompt tweaks

* linting

* gracefully handle removed attributes

* Refactor scene reference handling in delete_changelog_files to prevent incorrect deletions. Added a test to verify proper scene reference construction and ensure changelog files are deleted correctly.

* forked scenes reset memory id and are not immutable

* emit_status export rev

* Update RequestInput.vue to handle extra_params more robustly, ensuring defaults are set correctly for input.

* only allow forking on saved messages

* linting

* tweak defaults

* summarizer fire off of push_history.after

* docs

* : in world entry titles will now load correctly

* linting

* docs

* removing base attrib ute or detail also clears it from shared list

* fix issue where cancelling some generations would cause errors

* increase font size

* formatting fixes

* unhandled errors at the loop level should not crash the entire scene

* separate message processing from main loop

* linting

* remove debug cruft

* enhance error logging in background processing to include traceback information

* linting

* nothing to detemrine of no model is sent

* fix some errors during kcpp client deletion

* improve configuration issue alert visibility

* restore input focus after autocomplete

* linting
2025-10-25 14:06:55 +03:00

12 KiB

2 - Initial Nodes

2.1 - Scene Loop

In the Infinity Quest Dynamic tab you will see the node editor on the left and the scene history on the right.

To begin with we need to ensure that our scene has a custom Scene Loop.

The Scene Loop is the main node that will be used to drive the scene. It is where turn selection and other scene logic is handled.

For this scene we are interested in setting up the initial story premise in a dynamic way.

We do not care about changing any of the actual loop logic.

With this in mind we can extend a new scene loop from the default talemate loop. This will give us a copy of the default loop that we can add to while keeping the rest of the loop logic up to date with any future improvements.

The scene-loop module should already be selected in the :material-tree-view: Modules library.

Scene Loop

Click the :material-plus: Create Module button and in the menu select :material-source-fork: Extend Current.

Extend Current - Scene Loop

In the modal leave everything as is and click Continue.

This will create a copy of the scene loop node and add it to the scene.

This copy is owned by the scene and you can modify it.

The node editor will automatically open to the copy.

Scene Loop - Extended

!!! info "Module colors" - Modules owned by the scene are colored purple. - Modules imported from the templates directory are colored brown. - Modules owned by talemate are colored grey.

!!! info "Editor navigation" - Hold mouse and drag to pan the canvas. - Mousewheel to zoom in and out.

!!! info "Locked groups" In the node window you will see a bunch of (Inherited, Locked) groups. These come from the default talemate loop that was extended and cannot be edited or changed in this copy.

**The benefit:** If the default talemate loop is changed in the future, this copy will automatically inherit the changes to these nodes.

![Scene Loop - Extended - Node Editor view](./img/2-0020.png)

Read the [Node Editor - Inheritance](/talemate/user-guide/node-editor/core-concepts/module-inheritance/) documentation for more information about how inheritance works in the node editor.

2.2 - Hooking into scene initialisation

Generating a story premise is something that must happen at the start of the scene.

We need to somehow hook into the scene initialisation.

We can do this using an event module.

!!! info "Event modules" Events are signals sent by talemate during the scene loop. There are many different events and the Event module is a node module that can listen to a specific event and do stuff when it happens.

Learn more about events in the [Events](/talemate/user-guide/node-editor/core-concepts/events/) documentation.

!!! warning "Clear selection" If you have any nodes selected from your earlier playing around and familiarizing yourself with the node editor, make sure you deselect them now.

Just click on an empty space in the canvas to deselect all nodes.

Find the :material-plus: Create Module button and select :material-alpha-e-circle:Event.

Create Event

In the modal fill in the Name and Registry fields:

  • Name: On Scene Init
  • Registry: infinity-quest-dynamic/$N

The registry value determines where in the node creation menu the new module will exist. Its also a unique id for the module itself. $N will be replaced with a normalized version of Name.

Create Event Module - Modal

Click Continue.

The event module will be created and automatically loaded. You should be presented with an empty node canvas.

Event Module - Created

For now, go back to the Scene Loop by clicking on it in the :material-group: Modules library.

--8<-- "docs/user-guide/howto/infinity-quest-dynamic/.snippets.md:load-scene-loop"

Double click the canvas above the Prevent Infinite AI Turns group.

The Search for Node window will open up.

Type on scene into the Search field and select the On Scene Init node that we created moments ago.

Scene Loop - On Scene Init

!!! note "Alternatively - Right click for node context menu" You can also right click on the canvas above the nodes and select Add Node to add a new node.

The path should be `Add Node > infinity-quest > On Scene Init`

![Scene Loop - Right click for node context menu](./img/2-0008.png)

!!! tip "When extending a module - place custom nodes above the inherited nodes" Its good practice to place custom nodes above the inherited nodes.

The idea being that the original node will extend down the canvas and the space above will be available for custom nodes.

Once the On Scene Init node is added, it should appear where your mouse was when you initiated the node creation.

Scene Loop - On Scene Init

Click on the event_name node property and type in scene_loop_init.

Scene Loop - On Scene Init

Next click Save in the top right of the node editor. Save Graph button on upper right of node editor

--8<-- "docs/snippets/common.md:save-graph"

We are now hooked into the scene initialisation and can start working on dynamic scene creation.

2.3 - Testing the scene initialisation

Lets test that this works by adding some simple generated narration on scene initialisation.

Open the On Scene Init node module.

--8<-- "docs/user-guide/howto/infinity-quest-dynamic/.snippets.md:load-on-scene-init"

Search for the following nodes and (remember double click for search or right click for node context menu) add them to the canvas:

  • Generate Progress Narration - This node will be used to generate the introduction text, using the narrator agent.
  • Make Bool - We will use this as a basic ON state for the generation node.
  • Make Text - This will be used for us to provide instructions to the narrator agent.
  • Set Introduction - This will store the generated introduction text with the scene and update it in the scene history.

Once you have added all the nodes, hook them up like so:

Scene Loop - On Scene Init

!!! note "How to connect nodes" Nodes have input and output sockets.

Output sockets are on the right and input sockets are on the left.

Drag from the right-side socket of the node you want to connect from to the left-side socket of the node you want to connect to.

In the Make Text node click on the value node property and type in

Generate the introduction to a random exciting scenario 
for the crew of the Starlight Nomad

Hit Ctrl+Enter to submit the instruction.

--8<-- "docs/snippets/common.md:save-graph"

Click the :material-play: button in the top right of the node editor.

Play Button

If everything is hooked up correctly you should see the Generate Progress Narration node work for a bit and then the introduction text should be updated from its generation.

Scene Loop - On Scene Init

Updated introduction

Keep playing the module to see the introduction text being updated with each new generation.

You can then also test this outside of the node editor by switching to gameplay mode in the scene tools.

Gameplay Mode

It will load the scene and the intro text should update once more.

Switch back to the node editor using the same menu.

2.4 - Ok, but this happens every time the scene is loaded?

Currently - yes. Which is not what we want.

So lets change that.

--8<-- "docs/user-guide/howto/infinity-quest-dynamic/.snippets.md:load-on-scene-init"

In order for this to happen only once during the lifetime of the scene, we need to do a couple of things.

  1. Once we generate an introduction, we need to set a permanent state variable to indicate that we have already generated an introduction.
  2. Check if the introduction is already set. If it is, we skip the generation.

First lets organize the nodes a bit. Its generally recommended to use groups liberally and as soon as possible, as it keeps the canvas clean and easy to understand.

!!! note "Groups" Groups are a way to organize nodes in the node editor.

They are useful for keeping the canvas clean and easy to understand.

They can be resized and moved around like any other node, all nodes within a group will be moved together.

:material-resize: To resize a group, drag its lower right corner.

:material-cursor-move: To move a group click on a blank area in it and drag.

Right click the canvas and click Add Group.

Resize and move the Group so it encompasses the current nodes.

!!! note "Alternatively"

Hold `ctrl` and drag a rectangle to select all 4 nodes.

Then right click the canvas and select `Create group from selection`. Deselect the nodes after.

Then right click the group and select Edit Group > Title and title it "Generate Introduction".

Introduction Group

Next remove the Make Bool node as we will not be needing it. (Select it and press the Delete key)

Find and add the following nodes to the canvas:

  • Get State - We will use this to check if the introduction has been generated.
  • Set State - We will use this to set the introduction as generated.
  • Switch - We will use this to only generate the introduction if it has not been generated yet.

!!! learn-more "Learn more about states and switches"

- [State Management](/talemate/user-guide/node-editor/core-concepts/states/)
- [Switches and conditional routing](/talemate/user-guide/node-editor/core-concepts/switches/)

2.4.1 - Setting the state

!!! note "Instructions going forward" Going forward node connection instructions will be provided in the format:

`<Node>.output_name` :material-transit-connection-horizontal: `<Node>.input_name`
  1. <Set Introduction>.state :material-transit-connection-horizontal: <Set State>.value
  2. In the Set State node set the name field to intro_generated and the scope to game.
  3. Shift+Click the Set State node title to auto-title it.

!!! note "Auto titling" This is a feature some nodes have that automatically titles the node based on the value of their properties. In the case of the Set State node, it will title the node to SET {scope}.{name}, so in this case SET game.intro_generated.

Hold `Shift` and click the node **title** to auto-title it.

With this we're essentially saying if the Set Introduction node is executed set the intro_generated state variable to true.

2.4.2 - Checking the state

  1. <Get State>.value :material-transit-connection-horizontal: <Switch>.value
  2. In the Switch node set the pass_through field to false.
  3. <Switch>.no :material-transit-connection-horizontal: <Generate Progress Narration>.state
  4. <Switch>.no :material-transit-connection-horizontal: <Set Introduction>.state
  5. In the Get State node set the name field to intro_generated and the scope to game.
  6. Shift+Click the Get State node title to auto-title it.

Here we are using the Switch node to only route to the Generate Progress Narration node if the intro_generated state variable is false or not set. (or not truthy, for people familiar with this concept)

!!! note "State socket" The state socket is a REQUIRED pass-through socket that can be fed any value.

Its main purpose is to control the activation of a node. If the node has a state socket and the state socket is not connected or the connection is not active the node will not be executed.

Scene Loop - On Scene Init

!!! tip "Double check!" Reminder to double check that you have set the scope to game in both the Get State and Set State nodes.

--8<-- "docs/snippets/common.md:save-graph"

Now clicking the :material-play: button should only generate the introduction text once.

And you can verify that the game state has been saved by opening the Debug Tools and then the Edit Scene State window.

Open Scene State Editor Scene State Editor

!!! info "Debug Tools" The Debug Tools are a set of tools that are used to debug the scene, AI prompts and other things.

They are accessible by clicking the **:material-bug:** button in the top right of the talemate window.