Howdy, Stranger!

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

SugarCube: Scripting a multiple choice test

Gentlemen,

I try to script a simple multiple choice test with ten questions printing the result in the end. Not a difficult task doing it for SugarCane as I already did it and it worked well. In SugarCube however it does not print the result.

The code for a question (the content is German, I hope you don't bother):
<p style="text-align:justify">Wo ...</p>

<<radiobutton "$choice1" "Russland">>Russland
<<radiobutton "$choice1" "Rumnien">>Rumnien
<<radiobutton "$choice1" "Bulgarien">>Bulgarien

<<button "Zur zweiten Frage" "Frage_zwei">><</button>>
Checking the answer and adding +1 to the final result if it is correct:
<<if $choice1 eq "Bulgarien">><<set $result = $result + 1>><<endif>>
Printing the final result:
<<print $result>> von 10

In the start passage I set the variable $result to 0. In the end the result is not printed at all. To be honest: I don't know whether there's a problem with the print macro or the variable itself. So where is my mistake? I'd be grateful for every hint you can offer.

Comments

  • It works fine for me.  Are you not doing something like the attached example?

    Also, as a recommendation, you should do $variable initialization within the StoryInit special passage, not Start.
  • Greetings Exile,

    when I copied the $variable inizialisation into the StoryInit special passage, just as you said, everything worked perfectly. Thanks a lot for your advise and the fast reply.
Sign In or Register to comment.