Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Checking the history for previously visited passages.

Hi,

Newbie here.

I'm using Harlowe and I'm trying to trim the exit links of passages in a Twine-based book so that they only show passages that the reader hasn't already visited.

I've tried both the following:


(unless: ((history:) contains "Check the manacles 46"))Check the manacles->Check the manacles 46

(if: (history:) contains "Check the manacles 46")[](else:)Check the manacles->Check the manacles 46


But for the case where the passage 'Check the manacles 46' hasn't previously been visited, I get the following results (where the first line is the current history):


Start,The Awakening,Look at cell 46

The (unless:) command should be assigned to a variable or attached to a hook.->Check the manacles

The (else:) command should be assigned to a variable or attached to a hook.->Check the manacles


The test to see if a string is in the history (as follows) works fine.

(if: (history:) contains "Look at cell 46")[Found the string]

I'm really surprised that the second piece of code doesn't work, as that is just a simple example of what the (else:) macro is supposed to do, isn't it?

The only strange thing that I can see in the code, is that the colour of the number in the text string I am using for the test is different to the rest of the text in the string, which I don't understand seeing as it is also inside the quotes and should be being treated as text rather than a number. However, It is also a different colour in the standard if test line of code, which works fine, so a data typing mismatch problem can't be the cause the problem.

Anyway, if anyone can shed light on this problem, it would be very much appreciated. And, I'm quite willing to be told I'm doing something stupid here, because I'm new to the language.

I'm also happy to try an alternate approach, if there's a better one available in the language.

Cheers.

phillberrie.

Comments

  • The (unless:) and (else:) macros in your examples are missing the open and close square brackets of their associated hooks.

    The result of your (history:) contains "Look at cell 46" expresion is either true or false, you can use the not Boolean operator to invert a true result to false and a false result to true.

    Try the following, note the usage of open and close parenthesis around the core expression.
    (if: not ((history:) contains "Look at cell 46"))[ [[Check the manacles->Check the manacles 46]]]
    
  • Excellent. Thank you very much. It's sometimes the simplest thing...
Sign In or Register to comment.