简体   繁体   中英

What is the purpose of some fields in DSL in Dasha?

I want to know for what we need following fields:

  • node
  • do
  • digression
  • disable
  • goto
  • next
  • transitions
  • set
  • exit
node call_reason
{
    do
    {
        digression disable sayHi;
        goto next;
    }
    
    transitions
    {
        next: goto how_are_you;
    }
}

I suppose, you are asking this question because you are a little bit confused about syntax, I'll try to make it clear.

Nodes and Transitions

DashaScript is the language for describing automated conversations. Basically, any conversation script consists of

  • nodes - states of your conversation (please, see node doc )
  • transitions - relations between nodes that are described by conditions of switching from the current node to the another. There are three different kinds of transitions, eg instant transition that is used in code of your example (please, see transitions doc ).

In some sense, the scripted conversation can be thought of as a graph . In this case, nodes and transitions can be interpreted as vertices and edges of a graph, respectively.

Hence, node and transition define the structure of your conversation script.

Every node has subsection do where you can specify actions and instructions you want to be performed in this particular node .

Also, node may have subsection transitions which is used to specify conditions of switching a current state to another.
Every event-transition (like transition on event and timer transition) specified in this section has the following syntax: <transition_name>: goto <node_name> on <switching_condition> .
Instant transitions (like the one used in your code) have no conditions: <transition_name>: goto <node_name> . To execute such transition, it must be called in section do of current node with goto instruction.

Also, there are special nodes that can be visited from any state. These nodes are called digressions. (see digressions doc ). They are used to make fast reactions in your conversation and return to main branch of conversation. To control digression, we have mechanism of enabling/disabling them (see digression-control doc ).

So, in your example, the node with name call_reason has section do where you disable degression-node and then instant transition with name next is executed.

All entities of DashaScript language mentioned above are described in program structure docs . I would recommend you to check it out, since there are more important entities that you might need to know about.

Set

set is the instruction that is used for assigning a value for some variable. Example:

node some_node
{
    do {
        var some_variable: number = 1;
        set some_variable = 2; // now some_variable has value of 2
    }
}

Exit

exit is the instruction that interrupts the dialog.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM