Raconteur, a new way of writing for the Undum engine

I can see it. :slight_smile: I can’t promise a fix in the near future, but it makes sure I’ll be aware of it if I do get deeper into hacking Undum. You might want to bother Ian Milligton (At the trunk Undum repository) about it, too.

OK, I’ve submitted at the trunk Undum, too. :slight_smile:

I lied, I did end up writing a fix; see the issue on github.

I’m really enjoying Raconteur. It’s making Undum usable. As someone whose new to Javascript and Undum I would love to see more examples of Raconteur in action (I learn best by monkeying and tweaking existing code).

My plan at this point is to see when I can allocate time to write a Raconteur game that can act as a code example (Similar to Bronze and Alabaster to I7, so those would be real games and not just examples). That however may take a while. If someone wants to volunteer to do it, I’d be happy to help.

That would be great. I’m a novice to Undum and Raconteur but as I get more versed in them I might put together a youtube series on getting started. The biggest hangup is just reconciling what vanilla Undum can do in Raconteur.

Can you expand on what you mean by that?

Yea, what I mean is looking at Undum projects and figuring out how to get their example code to work in Raconteur.

The important thing to remember is that they should work out of the box - You have access directly to the Undum API, you don’t have to use Raconteur’s API. Raconteur situations and Undum situations can coexist in the same game, and you can use the old-fashioned way of manually adding situations on Raconteur. If spot an issue where that kind of compatibility isn’t happening, it might be a bug, so let me know.

Running into an issue trying to set qualities. If I include this:

situation ‘intro_explanation_3’,
content: (character, system) -> “”"
Scene Where You Get Stronger
#{system.setQuality(‘strength’, character.qualities.strength + 1);}
“”"
The appropriate strength quality does increase by 1 but in the body of my output text I see: “Scene Where You Get Stronger undefined”

I’m not sure why it is incrementing appropriately but throwing out that “undefined” error. I tried moving the line to:

after: (character, system) ->
    #{system.setQuality('strength', character.qualities.strength + 1);}

But then the strength quality does not increase at all. Any idea what I might be doing wrong?

Edit

Nevermind, right after posting this I figured out:

after: (character, system) ->
system.setQuality(‘strength’, character.qualities.strength + 1);

If you include something inside a string interpolation (#{like_this}), the return value from that something will be rendered as a string and joined into the string. system#setQuality, like all JavaScript functions with no explicit return value, returns undefined.

Keep in mind that, while a lot of the time content functions have only one statement (a big string which acts as the return value for the function) they don’t have to. This is totally valid:

situation 'increase-strength',
  content: (character, system) ->
    system.setQuality('strength', character.qualities.strength +1)
    """
    Your strength increases to #{character.qualities.strength}.
    """

In CoffeeScript, two things are true: First, every statement is an expression; second, the last statement of a function is its return value. One useful effect of this is that you can just write a function that is a single string statement with interpolations to generate text, but you don’t have to. Another effect of this is that, since if statements are expressions, you can include them inside an interpolation; but you must provide both halves of the if-else statement, because an if-expression that evaluates to false with no corresponding else will just evaluate to undefined:

"#{if value then 'value is truthy'}" # Will produce 'undefined' if value is falsy
"#{if value then 'value is truthy' else ''}" # Will produce empty string if value is falsy

Thanks, that actually really helped me clear up some stuff I was stuck on.