I am currently working on a Twine Story, and I have run into a problem. I am using SugarCube 1.0.34 with Twine 2. When I try to use <<print either>>, it ends up giving me the error "Error: <<print>>: bad expression: Unexpected token ILLEGAL".
If you would like to see what I attempted to use:
<<print either("Greg began to walk away when it asked 'May I have that gun?' Greg stopped and looked back at it.
Give
Continue", "The Riot member sat in silence. It stood perfectly still as Greg walked away. Greg turned a corner when he heard the squeak of a window opening.
RevKit")>>
Comments
The simpler solution is to break the code & content down like this:
That said, I'm going to suggest a slightly different solution than MoLoLu did for a few reasons.
I'd suggest something like the following. For this example I'm going to use line continuations and the special setup object—rather than using a story variable and unsetting it after.
The basic idea here is the following: Et cetera.
The deciding factor in these two methods is how much you want to format the code and how many escapes this will require. When you get into complex conditions, continuation becomes a major headache and virtually impossible to read. In very long text passages with dozens of conditionals, it can become hard to tell what lines are being continued vs which ones are not. In OP's example however this is a non-issue.
This is true except if you want to reference it later on. Consider a scenario with several branching plots that get 'recombined' at some point. After the recombination, you want to know which option the player took. If you don't store the variable, you now have to write multiple sets of passages, whereas with the stored variable you can check this later and adjust content accordingly. Again depends on story complexity and whether you want to reference the value down the line.
Case in point, as I noted when I mentioned line continuations, "Using <<nobr>> here really is unnecessary, since there's only a few extraneous line breaks you probably want to remove." (emphasis added)
If you need the value on a later turn, then I don't consider it a temporary value. This is a definition issue. My definition of a temporary value, as it relates to story formats, has two requirements:
Having a useful lifespan of several turns and requiring the use of story variables does not meet the bar.
This was one of the mistakes I made early on (and still do to some extent) - adhering to inefficient practices because I wasn't aware of alternatives. The implication of scope may be obvious to me now but it wasn't early on. From the example given, we can't infer the scope or future consequences. Hence my interest in elaborating on both methods, so @Kigner can decide which suits their needs best.