Howdy, Stranger!

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

Having trouble with the (display:) macro

Given these passages:

Room:
A boring room containing only a [desk]<desk_desc|.

(click: ?desk_desc)[(display: "Desk")]
Desk:
A [lamp]<lamp_desc| sits atop the desk.

(click: ?lamp_desc)[(display: "Lamp")]
Lamp:
A rusty old desk lamp.
When run, clicking the "desk" click macro link returns this:

[quote]A boring room containing only a desk.

A [lamp]<lampdesc| sits atop the desk.

(click: desc)[A rusty old desk lamp.]

I got the impression from the twine 1.4 documentation that the old <<display>> macro parsed everything from the passages it called up which sounds very useful and powerful. Am I correct that the Twine 2.0 version prints the code in a passage as plain text? Is this the intended behavior?

Thanks.

Comments

  • Actually, maybe the (display:) macro just doesn't like named hooks.  I tried turning the Desk passage lamp hook into a basic passage link, like this: [[lamp]], and that was parsed and printed as a link correctly when call up by the (display:) macro.
  • A bit of an odd work around - wrapping the named hook in a (print:) macro allows the earlier (display:) macro to parse it properly.

    Desk:
    A (print: "[lamp]<lamp_desc|") sits atop the desk.

    (click: ?lamp_desc)[(display: "Lamp")]
  • Two things I noticed:

    1. The (display:) macro within the (click:) macro is evaluated when the passage is shown not after the desk link is clicked.

    2. The (display:) macro does not seem to like the format of the hook names you are using because it modifies them. It removes the underscore between lamp and desc in the hook name, and removed lamp_ from the (click:) macro. Based on this I suggest not using underscores in your hook names.

    A [lamp]<lampdesc| sits atop the desk.

    (click: desc)[A rusty old desk lamp.]
  • Yeah, the underscore oddities seem to be a side effect of the (display:) macro issues with named hooks. When it parses the underscores they're removed and the word that follows is italicized. With or without the underscores (display:) turns named hooks into plaintext. Wrapping the named hook in a (print:) macro allows it to parse as expected, even with underscores in the hook name.
  • This is a minor bug which I hope will be fixed within the week.
Sign In or Register to comment.