Setting values as "true" after seeing multiple passages

I'm having trouble with figuring out how to set a value as true only after seeing everything the section has to offer. There are three passages, and each set the value as true, but I don't know how to specify that the player must see all three sections before setting said value as true. Any help is appreciated!


I'm not sure if this will work, but I think you can just use a turn counter... like:

[[Section]]:

You see [him], [her], and a [dog]

[him]: 
Text
[her]:
Text
[dog]:
Text

[@3]: value={true}

Hello.

Example 1

Use an integer variable to count:

@title Test Game 1

@set seenAllThree = 0

This game has three passages.

I want to know if you've seen all three of them.

[passage1] [passage2] [passage3]


[passage1]:
@inc seenAllThree

This is passage 1.

You have now seen {seenAllThree} out of 3 passages.

{if seenAllThree=3:[[CONTINUE]]}

[passage2]:
@inc seenAllThree

This is passage 2.

You have now seen {seenAllThree} out of 3 passages.

{if seenAllThree=3:[[CONTINUE]]}

[passage3]:
@inc seenAllThree

This is passage 3.

You have now seen {seenAllThree} out of 3 passages.

{if seenAllThree=3:[[CONTINUE]]}

[[CONTINUE]]:
# GAME OVER

REFERENCE

https://docs.textadventures.co.uk/squiffy/attributes.html


Example 2 (if you KNOW you only have 3 passages in the section AND each passage can only be clicked once)

Use a turn script. In this case, the 3rd passage:

@title Test Game 2

This game has three passages.

I want to know if you've seen all three of them.

[passage1] [passage2] [passage3]


[passage1]:
This is passage 1.


[passage2]:
This is passage 2.


[passage3]:
This is passage 3.

[@3]:
You saw all the passages.

[[CONTINUE]]

[[CONTINUE]]:
# GAME OVER

REFERENCE

https://docs.textadventures.co.uk/squiffy/turncount.html


Ah, Mr. Dot beat me to it.

To correct that last bit of his code:

[[Section]]:

You see [him], [her], and a [dog]

[him]: 
Text
[her]:
Text
[dog]:
Text

[@3]:
@set value

I think the [@3]: solution is probably the neatest. You can also use [@last]: as a shortcut for the number of passages in the current section. (Note that this counts the number of times the player has clicked a passage link since they entered the section - if there's more than one link pointing to the same passage, it might be possible to visit the same section more than once, which I think will mean that your @3 or @last passage could trigger early.

It also means that if the player can leave that section and then come back, it will only count the number of passages they've read this time.


If you want to check that they've all been seen rather than counting clicks, you could use KV's method 1, or use Javascript.
The JS expression $.grep(Object.keys(squiffy.story.section.passages), x => !squiffy.story.seen(x)).length returns the number of unseen passages in the current section. So you could do:

    squiffy.set('seen_all_passages', $.grep(Object.keys(squiffy.story.section.passages), x => !squiffy.story.seen(x)).length == 0)

That will set the attribute seen_all_passages to true if all the passages in the current section have been seen.
Unfortunately, this suffers from the same idiosyncrasies as seen in general. Basically, it only looks at the passage name to see if it's been seen. So if two sections have a passage with the same name, there's no way to determine which one of them the player has seen. So it really checks if the player has seen all the passages in this section, or passages elsewhere with the same names as the ones in this section, or sections with the same name as those passages.

Unfortunately, getting around this would need some significant changes to how Squiffy's seen function works.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums