Howdy, Stranger!

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

Sugarcube cyclinglink variable to change passage

I'm trying to use Sugarcube v1.0.10 and the Sugarcube version of cyclinglink to determine which passage the player goes to next. I thought that cycling the link was supposed to change what's assigned to the variable, but it doesn't seem to be.

I wrote this:
<<cyclinglink "$heat" "off" "low" "high" "fearsome">>

[[go|$heat]]
and I created passages called "off", "low", etc.

No matter what I cycle the link to, when I click "go" I end up at the passage called "off". The "replacelink" macro is "Removed pending update". Is there a problem with v1.0.10 and the cyclinglink macro?

Comments

  • I believe that SugarCube does not have its own cyclinglink macro, are you talking about the one written by Gregory Avery-Weir?
  • tedc wrote:

    I'm trying to use Sugarcube v1.0.10 and the Sugarcube version of cyclinglink to determine which passage the player goes to next. I thought that cycling the link was supposed to change what's assigned to the variable, but it doesn't seem to be.


    Your problem stems from faulty expectations.  When you do this:

    [[go|$heat]]
    The variable $heat is evaluated immediately, as soon the wiki link is processed (i.e. early evaluation).  At that time, $heat will always be set to off.  What you seem to want is a link that evaluates $heat only when the link is finally clicked (i.e. late evaluation).

    Most wiki markup and macros evaluate $variable arguments as soon as they're processed.  Note: The setter portion of a wiki link and the contents of the &lt;&lt;click&gt;&gt;/&lt;&lt;button&gt;&gt; macros are not "arguments" and do get processed late (i.e. on click).

    Anyway, it's not pretty, but this will do what you want:

    <<click "go">><<run state.display($heat)>><</click>>

    tedc wrote:

    The "replacelink" macro is "Removed pending update". Is there a problem with v1.0.10 and the cyclinglink macro?


    No.  There are, as far as I know, no problems with &lt;&lt;cyclinglink&gt;&gt;.  The reason that the &lt;&lt;replacelink&gt;&gt; set is down because Leon issued a bugfix release not that long ago and I simply haven't gotten around to putting out a SugarCube version of it yet.


    greyelf wrote:

    I believe that SugarCube does not have its own cyclinglink macro


    Actually, it does (under: Downloads > Macros) have a port of Leon's macro.
  • I stand corrected, silly me looked on the macro documentation page. Its good to learn something every day. lol
  • Thanks, that's exactly what I needed!
Sign In or Register to comment.