Howdy, Stranger!

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

Destination of link set on that page

I want he destination of a link to change depending on how the player selects a cyclinklink. It would be something like this:

You give them a call. &#039;Hi, I&#039;m &lt;&lt;cyclinglink &quot;$call&quot; &quot;an intern&quot; &quot;a reporter&quot; &quot;an environmental protestor&quot;&gt;&gt;.&#039;<br /><br />[[Next|$call]]

That will not work because the link is set when the page is generated; changing $call will not rewrite the destination. So how do I do this?

Comments

  • You could link to a fixed passage and display the text of a random one using <<display>>.
  • That does seem the best option, thanks.
  • If you're using SugarCube, this should also work:

    <<click "Next">><<run state.display($call)>><</click>>
  • The wrote:

    I want he destination of a link to change depending on how the player selects a cyclinklink. It would be something like this:

    You give them a call. &#039;Hi, I&#039;m &lt;&lt;cyclinglink &quot;$call&quot; &quot;an intern&quot; &quot;a reporter&quot; &quot;an environmental protestor&quot;&gt;&gt;.&#039;<br /><br />[[Next|$call]]

    That will not work because the link is set when the page is generated; changing $call will not rewrite the destination. So how do I do this?

    Honest question: do you or anyone else think that I should tweak the link syntax so that the destination expression is evaluated lazily - as in, only at the moment of clicking?

    (One problem with this is that it would break the :visited CSS selector I added in 1.4.1, because it wouldn't be possible to determine visitedness initially.
  • Since you're soliciting. :)

    No.  I don't believe that these should behave differently:

    [[$a]]
    [[Go forth!|$a]]
    The $a should not receive early evaluation in one case (call time) and late evaluation in the other (click time).

    Nor do I believe it wise to make the (two basic) parts of the link & text syntax behave differently:

    [[$text|$link]]
    Since $text must be evaluated at call time, why wouldn't $link.

    Additionally, as noted, this would be a breaking change.  Beyond, what's already been mentioned, all existing code which functions like the following would suddenly fail:

    /% $a is "The Beach" %/

    [[Beach Party!|$a]]

    /% $a is changed to "Death Dungeon" %/
  • TheMadExile wrote:

    If you're using SugarCube, this should also work:

    <<click "Next">><<run state.display($call)>><</click>>

    That's what I'm looking for.

    Where are state methods like display documented by the way?
  • The wrote:

    Where are state methods like display documented by the way?


    Nowhere at the moment.  SugarCube's API docs were generally meant to document the differences between it and the old vanilla headers.  Times change, however, and putting more of the APIs into the docs is on my TODO list (in which case state.display(), which is part of the History prototype, would be found in the story API docs).
Sign In or Register to comment.