Multiple-State Entity

The fact that states contain a sub-state system is very powerful and useful, however it can get annoying when you need lots and lots of sub-states. When this happens it is usually more convenient to create multiple individual states. This workflow has a few advantages:

  • Set-lang numbers are per-state, so you won’t need to keep track of large indices
  • Goto-statements are more natural when going to states, rather than sub-states
  • Generally clearer and easier to manage

Template:

{
    "header": {
        "output_type": "here",
        "default_state": "welcome"
    },
    "states": [
        {
            "name": "welcome",
            "next": "loop",
            "text": [
                "Hi!",
                "Welcome to Highcastle Fortress.",
                "I heard the baker might have a quest for you...",
                "Well anyway, enjoy your stay!"
            ]
        },
        {
            "name": "loop",
            "next": "loop",
            "text": [
                "Pleasant weather!",
                "Howdy!",
                "Good day."
            ]
        }
    ],
    "entity": "default sirlich:multistate_example"
}

With comments:

{
    //header like normal
    "header": {
        "output_type": "here",
        "default_state": "welcome"
    },

    //We define two states, instead of one
    "states": [

        //First state contains welcome information, which should play the first time.
        {
            "name": "welcome",
            "next": "loop", //Transition to 'loop' after the welcome dialogue is over
            "text": [
                "Hi!",
                "Welcome to Highcastle Fortress.",
                "I heard the baker might have a quest for you...",
                "Well anyway, enjoy your stay!"
            ]
        },

        //Loop state contains pleasant, non-story related dialogue.
        //This keeps NPCs interesting, even when their primary focus is completed.
        {
            "name": "loop",
            "next": "loop", //Transitioning to loop keeps the dialogue looping forever.
            "text": [
                "Pleasant weather!",
                "Howdy!",
                "Good day."
            ]
        }
    ],
    "entity": "default sirlich:multistate_example"
}