Raw beginner having trouble with <<set>> and with printing variables

Please specify version and format if asking for help, or apply optional tags above:
Twine Version:2
Story Format: Sugarcube 2.34.1

I write this input:

<<set $cash to 5>>
Your cash: $cash

and I expect this output:

Your cash: 5

But I get this output:

Your cash: $cash5

Okay, that’s not displaying right. The word “set” should appear between the angle brackets above. Let me try commenting it out: /* <> */ Still not right. And the angle brackets should be doubled, two open angle brackets, then the word “set” and then two closed angle brackets.

An additional question, then: How can I display code in these conversations?

I don’t have this problem when I run Sugarcube 1.0.35.

Does anybody know how to fix the problem in version 2.34.1?

For the forum, you can type backticks around your code, or you can select it and hit the Preformatted text button (looks like </>). Not sure why you’d have that problem with SugarCube 2.34.1 – the code looks right to me…

Edit: yeah, it works for me. Is there anything else going on in your passage or your game that could potentially interfere with it?

1 Like

Are you in Test mode? If so, that’s why you’re seeing the extra information, they’re debugging views. Open the debug bar—bottom right of the page—and disable views to hide them.

Test files generated via the Play button and published files generated via the Publish menu item do not enable Test mode features.

SEE: SugarCube v2’s Test Mode Guide

1 Like

Try pasting this into your code:

<<set $cash to 5>>Your cash: $cash

and see if that works (I put it all on one line simply to prevent an extra blank line).

If that works (it should) and your code still has problems, copy and paste the problematic code within a text block here and we can take a look.

Hope that helps! :slight_smile:

P.S. As TheMadExile mentioned, make sure that, instead of the “Test” button, that you’re hitting the “Play” button to play your game. The “Test” button shows some debugging information, which might be what you’re seeing.

1 Like

Thanks! I’ll try it now:


Bingo! That takes care of that. :smiley:

Wonderful. I was playing an individual passage by clicking the play button below that passage. That must be a test-play button, because when I made that passage the start passage, and clicked the main play button, the problem went away. :smiley: