Automatic completion of <<if>> variables

0 votes
asked Sep 9, 2017 by KittyEden (150 points)
I'm working with Sugarcube 1.0.35 right now. There's a particular part of the game that I'm trying to put together and don't know how to- there's eleven separate variables.(all called $partone, $parttwo, and so on) that are either true or false at any given time. I want to make it so that when all variables are true, the game, no matter which passage the player is on at the time, sets a twelfth (separate) variable to be true as well.

Please tell me if I'm not making any sense/need to clarify any information. Help would definitely be appreciated!


1 Answer

0 votes
answered Sep 9, 2017 by RealityDev (1,130 points)
selected Sep 9, 2017 by KittyEden
Best answer

Would it be as simple as a PassageReady passage with an if statement in it, checking is parts one through to eleven are true and if so, setting $parttwelve to true as well? This would only update them upon loading a new passage (or reloading the current one), to my understanding, which may or may not get the full functionality you're looking for.

commented Sep 9, 2017 by KittyEden (150 points)
edited Sep 9, 2017 by KittyEden
This sounds about right from what I can tell, but I'm having trouble tracking down the information on how exactly to do it. Would you have a link for something that could explain PassageReady info?

EDIT: actually did manage to find a thing explaining PassageReady, but now I'm having trouble with sorting the <<if>> statements themselves. Mainly, I have no idea where to actually begin. HelP?
commented Sep 9, 2017 by greyelf (66,150 points)

Create a new passage and name it PassageReady, then place TwineScript something like the following within it

<<if $partone and $parttwo and $partthree and $partfour and $partfive and $partsix and $partseven and $parteight and $partnine and $partten and $parteleven>>\
	<<set $parttwelve to true>>\


commented Sep 9, 2017 by KittyEden (150 points)
it worked- thank you so much!
commented Sep 9, 2017 by TheMadExile (35,690 points)
reshown Nov 21, 2017 by klembot

There's no need for the <<if>> in this case.  You may set $parttwelve appropriately by assigning it the conditional subexpression.  For example:

<<set $parttwelve to ($partone and $parttwo and $partthree and $partfour and $partfive and $partsix and $partseven and $parteight and $partnine and $partten and $parteleven)>>

The parenthesis aren't really needed there.  I used them solely to visually set off the conditional subexpression.

I don't know if you will need to guard against $parttwelve being changed once its been set to true.  If you do, then you could do something like the following:

<<if not $parttwelve>>
	<<set $parttwelve to ($partone and $parttwo and $partthree and $partfour and $partfive and $partsix and $partseven and $parteight and $partnine and $partten and $parteleven)>>


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.