+1 vote
asked by (550 points)
So my game is about life in college and I want to let the player select their classes from a set list. I want them to have to take a certain amout of class (right now I'm thinking 7) but I'm not sure how to make them have 7 (or more) options selected in a checkbox list. The best example I can think of is Fallout's S.P.E.C.I.A.L. system at the beginning of the game.(except with checkbox's instead of multiple points to each stat)

Is there a way to do this?

1 Answer

+2 votes
answered by (60.1k points)
selected by
 
Best answer

If you're using checkboxes, then you'll have to count each value.

Assuming that you're simply using true/false values something like the following:

<label><<checkbox "$classOne" false true>> Class One</label>
<label><<checkbox "$classTwo" false true>> Class Two</label>

Etc.

Then you could do something like the following to count the number of classes which were picked:

<<set _classCount to [
	$classOne,
	$classTwo,
	$classThree,
	$classFour,
	$classFive,
	$classSix,
	$classSeven,
	$classEight,
	$classNine,
	$classTen
].count(true)>>\
<<if _classCount lt 7>>
/* Less-than 7 classes were picked. */
<</if>>

 

SEE: <<checkbox>> and <Array>.count().

commented by (550 points)
Thank you. This will do the job.
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...