Howdy, Stranger!

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

Variable inside of a link

As the title suggests, I'm trying to have a link change a variable. I am aware that this question has already been asked, but every answer I have found doesn't work. For reference, I am using Sugercube 2.9.0 in Twine 2.0. Thank you.

Comments

  • What version of Twine 2? Because, yes, it matters. It would have also have helped if you would have detailed what you'd tried before that didn't work.

    If you're using v2.0.11 or the beta for v2.1, you should be alright using setter links. Earlier versions would parse setter links improperly and the automatic passage creation code would do stupid things because of it.

    Your other option, which will work in any version of Twine 2, is to use the <<link>> macro (formerly <<click>>).

    Using setter links
    [[Take the diamond.|Next Passage][$hasDiamond to true]]
    

    Using <<link>>+<<set>>
    <<link [[Take the diamond.|Next Passage]]>><<set $hasDiamond to true>><</link>>
    
  • I am using v2.0.11, and for each method, I receive an error message.

    Apologies! An error has occurred. You may be able to continue, but some parts may not work correctly.
    Error: <<set>>: bad evaluation: invalad lift side in-

    Then it cuts off.

    Note, I did not use a bullion like you did in the example.
  • Strangedog wrote: »
    Apologies! An error has occurred. You may be able to continue, but some parts may not work correctly.
    Error: <<set>>: bad evaluation: invalad lift side in-

    Then it cuts off.
    The truncated error is a Twine 2 bug. Publish to file and then open it in a normal browser, you'll see the full error.

    Also, please show your code. It's hard to point out what's wrong with it without seeing it, even with an error message. And, please, copy-paste it into a code block—no retyping.

    Note, I did not use a bullion like you did in the example.
    I don't know of any definition of bullion aside from bulk quantities of precious metals, and other related obsolete usages. I don't think that word means what you think it means.
  • Strangedog wrote: »
    I receive an error message.
    Did you receive that error while using one of TheMadExile's examples (via cut-and-paste) or from a link you created yourself?

    If it was from a link you created yourself, could you post (using cut-and-paste) that link in your next reply so we can look at it. Please use the C button in the comment field's toolbar to wrap your example in code markup.
  • This is the line of code:
    <<link Domestic Skill>><<set $s-skill = "Field Medicine">><</link>>

    The rest of the error message reads: Apologies! An error has occurred. You may be able to continue, but some parts may not work correctly.
    Error: <<set>>: bad evaluation: invalad left side in assignment.
  • Your variable name, $s-skill, is invalid. I'd suggest reading the variables documentation for the details of what makes a valid variable name.
  • Ahhh, perfect. One more step in the right direction. Thank you so much! By the way, sorry for being such a novice.
Sign In or Register to comment.