idmillington / undum

A client-side framework for narrative hypertext interactive fiction.
https://idmillington.github.com/undum
MIT License
336 stars 80 forks source link

simpleSituation not accepting V2 Choices #23

Closed masterxodin closed 10 years ago

masterxodin commented 10 years ago

I'm running in to an issue creating a Choices menu on a simpleSituation. I know my syntax is wrong, but neither the documentation nor the tutorial have any examples of the proper syntax to use when adding choices to a simpleSituation in the js file.

This is what I've written:

spaceShip: new undum.SimpleSituation
(
    "<p>What shall I do?</p>\
    \
    <p class='transient'><a href='spaceEngineRoom'>Check on the\
    engines.</a></p>",
    {
    choices: "#shipboard",
    }
),

spaceEngineRoom: new undum.SimpleSituation
(
    "<h1>Engine Room</h1>\
    <p>The Engines are fine.</p>\
    \
    <p class='transient'><a href='spaceShip'>Return to the Bridge</a></p>",
    {
        heading: "Engine Room",
        diplayOrder: 1,
        tags: ["shipboard"]
    }
),

spaceMedBay: new undum.SimpleSituation
(
    "<h1>Med Bay</h1>\
    <p>The Medical Bay is fully stocked.</p>\
    \
    <p class='transient'><a href='spaceShip'>Return to the Bridge</a></p>",
    {
        heading: "Med Bay",
        diplayOrder: 2,
        tags: ["shipboard"]
    }
),

At the moment this returns an assertion error. Uncaught function (message) { this.message = message; this.name = AssertionError; }: You can't move to an unknown situation: s.

The documentation http://undum.com/doc/implicit.html offers a lot of info on how to generate choices, but offers no examples of choices: or System.writeChoices or System.getSituationIdChoices in use in an actual simpleSituation, and the tutorial doesn't use them either (every situation that uses them is in the html file instead of the js file). So unfortunately, I have nothing to compare against to figure out the errors in my syntax. Could anyone show me an example of how the coding for generating choices is supposed to look like in the js file when adding them to a simpleSituation?

idmillington commented 10 years ago

Thanks for this, we should definitely add an example to make it clearer.

The documentation for System.writeChoices says that it takes a list of ids, and the choices option in SimpleSituation does the same. So for now, you should be able to change

choices: "#shipboard"

to

choices: ["#shipboard"]

i.e. give it a list.

I haven't tested it on the code you gave, but I'm closing this issue, please reopen it if it doesn't solve your problem.