Adding Failed Attempts in Twine


I just wanted to know if anyone knows how to write a code on Twine sugarcube to implement failed attempts. So whenever the user submits an answer and if it is wrong points get deducted. I want them to be able to guess 3 times.

1 Like

How are you with variables? You are implementing points, so you know how those work.

Based on how you have your player submit an answer, you compare their answer to a value. If it matches, you add points. If it doesn’t match, you subtract them.

or you can link through correct or incorrect answers
:: passage 1

What is your dog's name?


:: rightanswer

Yay! You're right!
<<set $dollars = $dollars + 100>>

You won $100! Your score is now $<<print $dollars>>!


:: wronganswer
Oh, so sad, that's totally wrong! Lose $50!

<<set $dollars  =  $dollars - 50>>

You're left with a paltry $<<print $dollars>>...


Note this is axma/generic and exact code may not apply to your story format.

You might like to check Gulumige’s solution to this post:

1 Like