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": [
        "block.bamboo.step",
        "block.bamboo.step",
        "block.bamboo.step"

    ],
    "text": [ 
        "Hey there feller!",
        "How are you doing today?",
        "Are you enjoying Echo:NPC?"
    ],
    //List format accepts lists as well. In this case, the first sub-state
    //Accepts two transitions: proximity, and has_tag
    "transitions": [
        [
            "proximity 5",
            "has_tag some_tag"
        ],
        ["timer 5"]
        "interact"

    ]

    //You can define component_groups, components, custom_components etc in the same way
}

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"
    },
    "commands": {
        //Set-Lang accepts lists of arguments, allowing you to place multiple effects at a given sub-state
        "2": [
            "/say Example",
            "/say Command"
        ]
    },
    "text": [ 
        "Hey there feller!",         //Plays block.bamboo.step, because of the sounds list.
        "How are you doing today?",  //Will say "Example" and "Command", as well as the normal dialogue
        "Are you enjoying Echo:NPC?"
    ]
}

Formatting Set-Lang

Set lang arguments come in two types: Single number, and range. A single number simply adds that sub-state (see examples above). A range on the other hand, adds an entire range of sub-states. 1-10 for example will add sub-states 1 through 10.

Aliases exist for some numbers, such as first, second, and end.

Examples

Here are many example of set-lang:

{
    "name": "greetings",
    "length": 15, //We can define a length, to give meaning to the alias "end"
    "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", //Use "length" property to determine how many states to create
        "second": "Printed on the second state",
        "1, 4, 10": "Printed on states 1, 4, 10",
        "first-last": "Printed on all states",
        "1, 2, 10-15": "Printed on 1, 2, and 10, 11, 12, 13, 14, 15
    }
}