Points🔗

score, reward, correct, quiz, test, gamification

Points can be used just about anywhere in a program, but they're especially useful to include after multiple choice answers. If you want to award or take away points for correct or incorrect answers, you can do so using the *points keyword. The user will see them totaling up on their screen. Here's an example of how this works.

*question: How many licks does it take to get to the center of a tootsie pop?
	1
		Nice try.
	252
		*points: 2
		That's right! You got two points.
	1024
		*points: -1
		Nope, sorry! You lost a point.

In this example, users who guess "1" won't get any points, users who guess "252" will receive 2 points, and users who guess "1024" will have 1 point subtracted from their point total. The total points a user has will remain on their screen. The user always starts with 0 points, but points only begin to be displayed after hitting a *points keyword for the first time.

You may want to assign lots of points in your program, but there may also be different types of points you want to assign. For example, let's say you have a quiz with lots of real questions and lots of trick questions. You may want to know how many points the user got on the real questions versus how many they got on the trick questions.

*question: If you have two apples and someone gives you two more, how many apples do you have altogether?
	2
		*points: 0 realQuestion
	4
		*points: 10 realQuestion

*question: If there are three unicorns and you take one away, how many do you have?
	1
		*points: 10 trickQuestion
	2
		*points: 0 trickQuestion

In this example, separate totals will be calculated for the user's realQuestion points and their trickQuestion points. However, unlike the first example, users will not see how many realQuestion or trickQuestion points they have. There won't be any data about points on the screen unless you explicitly tell the user how many points of a particular type they have. To do this, you'll write something like this:

Congratulations! You got {realQuestion} points on all the real questions and {trickQuestion} points on all the trick questions. In total, you got {realQuestion + trickQuestion} points.

By putting the unique name for the type of point in {braces}, you are able to tell the user how many points they've gotten for that type of point. You can also use math functions to add up the total number of points for the user.

You can assign some points with a *type and some points without a *type. If you do, the user will see the running tally of non-typed points on their screen, but any points with a *type will not be added to that tally.

*question: How many licks does it take to get to the center of a tootsie pop?
	252
		*points: 2
	1024
		*points: -1

*question: If there are three unicorns and you take one away, how many do you have?
	1
		*points: 10 trickQuestion
	2
		*points: 0 trickQuestion

In the above example, users will be able to see new points added onto their screen when they answer the tootsie question, but their answer to the unicorn question will not affect the score on their screen because it has a type associated with it. You'll have to tell the user how many trickQuestion points they got separately.

Points are not only valid beneath questions, though. You can merrily sprinkle the *points keyword just about anywhere in your program.

For example:

You made it to screen 3,417 of my diary!?! You're super swell!
Here's 10,000 points!
*points: 10000

The *points keyword can also work anywhere in your program with special types of points (points that don't get visibly added on the corner of the screen, but are saved nonetheless).

You just completed the optional homework!
*points: 10 brownie_points

You can also set the user's points to a specific value like this:

>> points = 100
You've automatically advanced to 100 points!

If you ever want to hide the users' points from the top-right of the screen, doing so is a breeze:

Wowee, 200 points!
*points: 200
*button: Oh golly-gee!
Wait, where'd they go??
*points: hide

The points are no longer visible to the user, but the value is still stored safely away. They'll still display the correct total if you decide to re-show them on the screen again later.


Next: