Tutorial Entity

This tutorial will show example code for a tutorial NPC. A tutorial NPC is an NPC which introduces a player to the map by reading some set dialogue. The NPC should then respectfully disappear so he doesn’t bug the player any more.

Template:

{
    "header": {
        "output_type": "here",
        "default_state": "welcome"
    },
    "states": [
        {
            "name": "welcome",
            "next": "loop",
            "transitions": {
                "1": ["proximity 10"],
                "2-end": ["timer 3"]
            },
            "commands": {
                "5": [
                    "/playsound random.xporb @a",
                    "/give @p minecraft:iron_sword"
                ]
            },
            "text": [
                "Hi!",
                "Welcome to Highcastle Fortress.",
                "This is a most beautiful kingdom, but very dangerous!",
                "Remember not to go outside the walls without a dagger.",
                "Here, take this, it was my fathers.",
                "Well anyway, enjoy your stay!"
            ]
        },
        {
            "name": "loop",
            "next": "loop",
            "transitions": {
                "all": [
                    "interact",
                    "reverse_proximity 20 echo:despawn"
                ]
            },
            "text": [
                "Pleasant weather!",
                "Howdy!",
                "Good day."
            ]
        }
    ],
    "entity": "default sirlich:test"
}

With comments

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

    //We include two states, much like the multistate example
    "states": [

        //First state introduces the map
        {
            "name": "welcome",
            "next": "loop", //Transition to loop when the introduction is over.
            "transitions": {
                "1": ["proximity 10"], //trigger the dialogue chain based on proximity, so the player doesn't
                                       //miss the NPC.
                "2-end": ["timer 3"]   //The rest of the dialogue should play on a timer
            },

            //Give player a sword at the fifth sub-state
            "commands": {
                "5": [
                    "/playsound random.xporb @a",
                    "/give @p minecraft:iron_sword"
                ]
            },

            //Introduction text
            "text": [
                "Hi!",
                "Welcome to Highcastle Fortress.",
                "This is a most beautiful kingdom, but very dangerous!",
                "Remember not to go outside the walls without a dagger.",
                "Here, take this, it was my fathers.",
                "Well anyway, enjoy your stay!"
            ]
        },

        //Loop will play senseless dialogue until the player leaves the area 
        {
            "name": "loop",
            "next": "loop", //Keep the dialogue looping
            "transitions": {
                "all": [
                    "interact", //Clicking will play the next dialogue, in a loop

                    //When the player gets 20 blocks away, the entity will despawn itself
                    //This is good so the entity doesn't despawn in front of the player
                    "reverse_proximity 20 echo:despawn" 
                ]
            },
            "text": [
                "Pleasant weather!",
                "Howdy!",
                "Good day."
            ]
        }
    ],
    "entity": "default sirlich:test"
}