Hi,
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.
Hi,
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.
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.
:: passage 1
What is your dog's name?
[[Lassie|rightanswer]]
[[Spudnik|wronganswer]]
:: rightanswer
Yay! You're right!
<<set $dollars = $dollars + 100>>
You won $100! Your score is now $<<print $dollars>>!
[[continue]]
:: wronganswer
Oh, so sad, that's totally wrong! Lose $50!
<<set $dollars = $dollars - 50>>
You're left with a paltry $<<print $dollars>>...
[[continue]]
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: