Howdy, Stranger!

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

Doing something when link/passage is clicked?

Hey, i am currently trying to blend in with sugarcube. Already got some stuff out of the documentary.

But what i coudn´t find because i cannot put it into the right words:

How to do something (e.g. changing variables) when something is clicked?

The Intention Looks like this:

Passage "Stayhere"

<<set $text to "Hello">>
<<print $text>>

[<<set $text to "Okay let´s talk">>Stayhere| Let´s have a talk]]

same question:
How to do something (e.g. change variables) when someone clicks on an internetlink.

Comments

  • Which version of SugarCube are you using?
  • 2.12.1.
  • You may either use a setter link or the <<link>> macro.

    Setter links will tend to be a bit shorter. OTOH, <<link>> macros give you greater flexibility as they allow you to do as much as you need to when the link is activated.


    Setter Link
    [[Link text|Passage name][$text to "something"]]
    
    TIP: Never put extraneous whitespace around the passage name in links. Twine 2 erroneously takes that whitespace to be significant.


    <<link>> macro
    <<link [[Link text|Passage name]]>>
    	<<set $text to "something">>
    <</link>>
    
    /* OR */
    
    <<link "Link text" "Passage name">>
    	<<set $text to "something">>
    <</link>>
    
  • thank you. that should do.
Sign In or Register to comment.