Blanks Widget

 

The blanks widget is called by inserting the - blanks: in the response plus a ^ choices: a / b / c. After, each choice must have a corresponding trigger. It is also important to note that you tell the application where to put the blank by including [[blank]]. Each response may only include ONE [[blank]]

The basic code for the blanks widget is:

> topic blankswidget
  
  + start
  - blanks: When I was a kid, I always [[blank]] with my brother.
  ^ choices: fought / fights/ will fight

  + fought
  - guide says: XXXX
  ^ next: exitcontinue

  + (fights|will fight)
  - guide shouts: Check your verb conjugation
  ^ next: start

  + exitcontinue
  - continue: next
  ^ showInput: no
  ^ say: start

< topic

Some important things to take note of in above code sample:

  1. The correct answer is ALWAYS the first choice
  2. Each ^ choice: matches to a trigger later on to tell the application where to go next.
  3. The ( ) punctuation in the in the trigger. Allows you to have multiple triggers give the same response.

Stringing together multiple blanks widgets

Blanks are a great way to bring interactiveness and learning to dialogues. You can string together multiple blanks widgets to create dialogues between the application and the character. Look at the example code below of the player describing his experience working with his brother as a kid. Keep an eye out for places where the application will get confused and crash

> topic blankswidget
  
  + start
  - blanks: Back when I was a kid, I always [[blank]] with my brother.
  ^ choices: fought / fight/ will fight

  + fought
  - guide says: You are adults, I hope that you don't still fight now.
  ^ next: response

  + (fight|will fight)
  - guide shouts: Check your verb conjugation
  ^ next: start

  + response
  - blanks: No, we don't [[blank]] with each other any more.
  ^ choices: fight / fought/ will fight

  + fight
  - guide response: I'm glad to hear it.
  ^ next: exitcontinue

  + (will fight|fought)
  - guide shouts: I'm confused!
  ^ next: response

  + exitcontinue
  - continue: next
  ^ url: /lessons/example

< topic

Did you see how the application could get confused? Hopefully you noticed that by using multiple blanks together to create a dialogue, the example above created a situation where you have multiple triggers within the same topic with the same name. Remember that ALL triggers MUST be UNIQUE within a topic. So rather than creating a new set of triggers, we can create a new topic and reuse our previous triggers.

Creating and Linking New Topics together

Creating and chaining new topics is really quite easy. To do so, all you have to do is to append {topic=XXXX} to the end of the response and then include the next trigger in the ^ start: command. Next create a new topic name and include a + start code block. Look at the example below:

> topic firsttopic
  
  + start
  - guide says: This is the first topic {topic=secondtopic}
  ^ next: start

< topic 

> topic secondtopic

  + start
  - abby shouts: GREAT! This is the second topic

< topic

So now that we know how to link topics together, lets add and new topic called blankswidgetresponse and a {topic=blankswidgetresponse} rewrite the interactive story above in a way that the app can understand.

> topic blankswidget
  
  + start
  - blanks: Back when I was a kid, I always [[blank]] with my brother.
  ^ choices: fought / fight/ will fight

  + fought
  - guide says: You are adults, I hope that you don't still fight now. {topic=blankswidgetresponse}
  ^ next: start

  + (fight|will fight)
  - guide shouts: Check your verb conjugation
  ^ next: start
< topic > topic blankswidgetresponse

  + start
  - blanks: No, we don't [[blank]] with each other any more.
  ^ choices: fight / fought/ will fight

  + fight
  - guide response: I'm glad to hear it.
  ^ next: exitcontinue

  + (will fight|fought)
  - guide shouts: I'm confused!
  ^ next: response

  + exitcontinue
  - continue: next
  ^ url: /lessons/example

< topic

Leave a comment