Set-Lang

Whenever you want to add information into a state, Echo:NPC provides two possibilities:

  • List format
  • Set-lang format

As an example, lets look at a simple state, showing off the list format:

{
    "state_name": "greetings",

    //This is using the list format. Each list element points to a sub-state
    "text": [ 
        "Hey there feller!",
        "How are you doing today?",
        "Are you enjoying Echo:NPC?"
    ]
}

List format maps directly to sub-states. This state will create three sub-states:

  • greetings: Hey there feller!
  • greetings_2: How are you doing today?
  • greetings_3: Are you enjoying Echo:NPC?

Anything can be a list!

{
    "name": "greetings",

    //Sounds and text are "simple" lists, meaning it takes a list of strings.
    "sounds": [
        "block.bamboo.step",
        "block.bamboo.step",
        "block.bamboo.step"

    ],
    "text": [ 
        "Hey there feller!",
        "How are you doing today?",
        "Are you enjoying Echo:NPC?"
    ],

    //Lists of lists is allowed, or simply place the argument directly
    "transitions": [
        [
            "proximity 5",
            "has_tag some_tag"
        ],
        ["timer 5"]
        "interact"

    ]

    //Insert similar code for components. custom_components, component groups etc. 
}

Set Lang

Set-Lang arguments provide a more convenient way to write repeating information. Most of the time, you will use set-lang arguments.

Set-lang allows us to specify which sub-states are affected by each effect. When we write set-lang, the first argument is the sub-states we want to effect, and the second argument is the effect to apply

SELECTOR:           EFFECT:
"1-3":            ["timer 1"]

In the example above, the transition timer 1 will be added to sub-states 1, 2, and 3.

Example

{
    "name": "greetings",
    //Using the all key-word, we can attach the timer transition to all sub-states. 
    "transitions": {
        "all": ["timer 2"]
    },
    //Using the 1 key-word, we can attach this sound to the first state. 
    "sounds": {
        "1": ["block.bamboo.step"]
    },
    "text": [ 
        "Hey there feller!", //Plays block.bamboo.step, because of the sounds list.
        "How are you doing today?",
        "Are you enjoying Echo:NPC?"
    ]
}

Examples

Here are many example of set-lang:

{
    "name": "greetings",
    "length": 15, //If you don't use a list-like text array (the most common) you need to provide a length
    "text": {
        "all": "Printed on all states",
        "1": "Printed on the first state",
        "first": "Printed on the first state",
        "1-2": "Printed on the first and second state",
        "1-2, 7-10": "Printed on states: 1, 2, 7, 8, 9, and 10",
        "5-end": "Printed on all states greater than five",
        "second": "Printed on the second state",
        "1, 4, 10": "Printed on states 1, 4, 10",
        "first-last": "Printed on all states",
    }
}