Add points at the end of the game

I create a demo in which the player collect and lose points choosing the answers. I would like to ask if it is possible to add up the points that gains a player at the end of the game? not at the middle of game…

It probably makes the most sense to set the number of points as a variable that you increase or decrease when certain answers are clicked, but don’t display until the end.

So something like:

(link: "Next passage")[(set: $points to it + 1)(goto: "Next passage")]

Which does add or subtract the number over the course of the game, but you don’t have to show the number until the end, with a

(print: $points)

Actually refraining from doing the math until the end would be much more cumbersome, likely requiring you to create a separate variable for each question which you would then all add up at the end—which doesn’t make much sense unless it matters that even the code wouldn’t know the score until that point.

Hello,

I use this simple code.

In each passage with a question I will insert:

(set: $question to it + 1)

To the passage with the correct answer:

(set: $correctanswer to it + 1)

To the passage with the wrong answer:

(set: $wronganswer to it + 1)

In each of the following passages, or at the end of the game, I insert:

Number of questions $question ,

Correct answers $correctanswer ,

Wrong answers $badanswer ,

This is how you can display the number of lives or items that he has gained or lost in the game.

Just be aware you have listed two different variables: $wronganswer and $badanswer and they will need to match to display properly if they are referring to the same variable. :slight_smile:

Hello,

I’m sorry, maybe I explained it wrong.

I did it this way, but he created one passage for the correct answer and another for the wrong answer.

He inserted a variable in each. From each passage there was the same reference to the next question.

Maybe it would go like this:

What is Sailor’s most popular Pepek food?

(link-repeat: “IceCream”)[(set: $wronganswer to it + 1)]

(link-repeat: “Spinach”)[(set: $correctanswer to it + 1)]

[[Next question]]

But I don’t know what happens when a player clicks on both options.

Here is a link to the game in which I wrote the variables as I originally described and it works great.

www.uschovna.cz/zasilka/VCJ2IEHY4EPFD633-WVV

Jiří Škrába

image001.jpg

image002.jpg