Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Displaying [ ] symbols in a link to another passage

Hi there,

I'm trying to make a link to a new passage, but I want the visible text to include [ ] symbols, to represent an action rather than dialogue.

I tried this:
[[[Run to the Fermented Potato]]]

The link it creates displays correctly as "[Run to the Fermented Potato]" but the link doesn't work (displays an error in the next passage. Also, the next passage is automatically named "[Run to the Fermented Potato" (yeah just the first "[" ). I found this a bit odd.

I'm new to Twine, any help is much appreciated!

Comments

  • What story format and version?
  • edited April 2017
    For SugarCube 2.x, this works:
    [[`[link]`|passage]]
    

    For Harlowe 2.x, this works:
    (set: _link to "`[link]`")\
    [[_link|passage]]
    

    I couldn't get things to work in Harlowe without using a variable.

    I recommend using the two argument version of the link syntax for this (i.e. passage, not passage), so Twine 2 isn't running around making all kinds of crazy passages.

    Note that in both examples, we're using graves (`), not single quotes ('). The grave key is just above tab on most keyboards, to the right of the number keys.
  • In Harlowe (both 1.x and 2.x) a single open [ and close ] square bracket pair is used to represent a hook, this unfortunately causes issues when trying to display such a pair in text.

    The simple solution is to use HTML UTF-8 Unicode characters instead, you can find the codes for the square brackets in this Unicode Character Table.

    The following demonstrates three different link types:
    [[[Run to the Fermented Potato]->Run to the Fermented Potato]]
    
    (link: '[Run to the Fermented Potato]')[(go-to: 'Run to the Fermented Potato')]
    
    
    [&#91;Run to the Fermented Potato&#93;]<link|
    (click: ?link)[(go-to: 'Run to the Fermented Potato')]
    


    WARNING: You may of noticed that the Name of the target Passage does not include the square brackets (neither character or UTF-8 codes), this is because it is generally not a good idea to use punctuation/extended characters in a Passage Name.
  • Chapel wrote: »
    For SugarCube 2.x, this works:
    [[`[link]`|passage]]
    
    I do not recommend using a template string literal, as it will not work in older browsers. A regular string literal would be the thing to use. For example:
    → Using double quotes
    [["[link]"|passage]]
    
    → Using single quotes
    [['[link]'|passage]]
    
  • if you're using harlowe you could try this:
    (link: '[Run To The Fermented Potato]')[(goto: 'Run To The Fermented Potato')]
  • Deadshot wrote: »
    if you're using harlowe you could try this:
    (link: '[Run To The Fermented Potato]')[(goto: 'Run To The Fermented Potato')]
    
    warning: This method only works in Harlowe v1.x, in v2.x the '[Run To The Fermented Potato]' Link Text parameter is converted to an anonymous hook before being displayed which results in the square brackets being removed.
  • Thanks everyone!

    I'm using Sugarcube 2.14, sorry I didn't mention it, I thought I was posting in the Sugarcube 2.x category, but it seems to just have been the Twine 2.0 category. My bad!

    I went with TheMadExile's
    [["[link]"|passage]]
    

    It seems to work perfectly. Cheers!
Sign In or Register to comment.