Howdy, Stranger!

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

Checking if a user chose a specific passage (SugarCube)

I'm creating a game with branching choices. I know I can use visited() to check if a user has visited a certain passage, but is there any way to check if they actually chose that path?

For example, I have a birthday party scene with multiple presents. The user can click on each present passage to read a description and then either go back to the party or choose that gift. How can I check if they actually chose it, versus just visiting that page?

Thanks!

Comments

  • I am going to assume that the markup link that the Reader uses to describe the gift is not the same one they use to choose that gift.

    1. You can use variables to track choices the Reader makes, and in this case you have two different ways you can do this.

    a. Use a single variable to track which gift was chosen (eg. $giftChosen) and assign it the name of which gift was chosen. The $giftChosen variable would need to be initialized in your StoryInit passage like so <<set $giftChosen to "">>
    <<set $giftChosen to "Ferrari">>
    or
    <<set $giftChosen to "Porsche">>
    or
    <<set $giftChosen to "Trip to Hawaii">>
    
    b. Use a variable per possible gift option.
    You would need to initialize each of them to false (<<set $giftFerrari to false>>) and then set them to true if that gift was the chosen one.
    <<set $giftFerrari to true>>
    or
    <<set $giftPorsche to true>>
    or
    <<set $giftHawaii to true>>
    

    2. In the passage where they may the selection you would use Setter links like the following:
    notes:
    a. I don't know if you send the Reader to a single passage or individual passages per choice, so I will use a single passage but you can change that to individual passages.
    b. I am going to use a single variable to track which choice was made.
    [[Choose the Ferrari|Gift Chosen][$giftChosen to "Ferrari"]]
    [[Choose the Porsche|Gift Chosen][$giftChosen to "Porsche"]]
    [[Choose the Trip to Hawaii|Gift Chosen][$giftChosen to "Trip to Hawaii"]]
    

    ** Remember to first initialize whichever variables you use in your StoryInit passage.
  • Thank you so much!!!
Sign In or Register to comment.