Magnets/ Jumble Game

 

magnets

The magnets widget is called by inserting the - magnets: in the response. To separate the magnets, merely include a / at the different points in the sentence.

The magnets game works by taking the sentence that the player put together and then matching it to corresponding triggers within the topic.

The basic code for the magnets widget is:

> topic magnets

  + start
  - magnets: I am / the magnets / game.

  + i am the magnets game
  - guide says: Of course you are.

  + *
  - guide says: Huh? That sentence doesn't make sense. Try again.
  ^ next: start

< topic

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

  1. Capitalization and punctuation is ok in the - magnets: widget, but is NOT ok in the triggers. When writing the trigger, just write the correct sentence out in lowercase and without punctuation and the application will understand this.
  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.We will deal with this later in the page.

Punctuation – * and [ ]

It can be exhausting to have to write out all the examples for all the combinations for the magnets widget. Fortunately, you can use and [ ] to make your life much easier.

The * works in the triggers and essentially means anything. When we see it in a trigger, it tells the application to look for ANYTHING that doesn’t already match to an existing trigger. Another way to think of it is to think of it as a NONE OF THE ABOVE on a multiple choice test.

The [XXXX] is a really handy tool because it tells the application that XXXX is optional. If XXXX exists, then match it, if it doesn’t, then the application will move on. Look at the examples below

  + i am [also] a trigger
  - guide says: You are a trigger

  + *
  - guide says: You are something, but I'm not sure what it is.

In the above code, if

 

Leave a comment