Howdy, Stranger!

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

Regarding the (history:)

I am using Twine 2 with Harlowe 1.2.2

In some of my passages I use the "(history:) contains" to call certain hidden text to appear later into the story.
If a player hasn't visited the passage, then the player doesn't get to see that text, and therefore sometimes certain other variables or functions aren't called because the (history:) state is false.

I'd say I use it fairly often especially with regards to preventing extra lives from being given to the player when revisiting a passage where it was given.

However, there are a smaller amount of times when it is used for other fucntions like I mentioned in the first paragraph.

That being said, I have been using the debug-startup passage/function to test certain passages. However, I can't seem to figure out a way to force the history to contain any passage history.
Is there a way?

I have something like this in the debug-startup passage:
(set: $a to true)
(set: $b to true)
(set: ((history:) contains "Passage.") to true)

But when debugging any passage to test it, it gives me an error:
"I can't put a new value into the logic value 'false'."
Which I think means it can't do what I'm asking...so to be clear...is there another way to do what I'm attempting to do?

I'd really prefer to not have to go through and set up new variables for particular passages that I later call on for these situations, but if I must, I must.

Thanks.

Comments

  • As the (history:) macro documentation explains the macro returns an array, that array contains a copy of the list of passage names stored in the story's Timeline/History.

    Modifying the contents of the returned array has no effect on the History/Timeline system.

    because the (history:) state is false
    The passage names contained in the returned array have no state, a passage name is either there or it is not.

    The contains operator/keyword is used to determine if an array contains one-or-more instances of whatever you are searching for, it returns either true or false depending on where the item was found or not.

    Your code example was the equivalent of saying either (set: true to true) or (set: false to true) depending on if the array contained "Passage."

    The solution is to use one or more variables, maybe something like the following:
    In the debug-startup passage...
    (set: $debugA to true)
    
    
    In the passage(s) being tested....
    (if: (history:) contains "Passage" or $debugA)[
    .... Do something ...
    ]
    
  • Additionally, is there a way to clear all of the history without clearing any other variables throughout the game?

    My purpose of doing that would be to let the player start the game over, but retain "achievements" and extra lives already accumulated.
  • edited April 2016
    As far as I know...

    Simple answer: No

    The only built-in way I know of to reset history is the (reload: ) macro which results in everything being reset.

    Complex answer: Maybe

    You would need to use Javascript to:
    1. Access the story's variables (there is no documented way to do this)
    2. Store the variables values somewhere that wont be effected by the (reload:) macro (a cookie or local storage may work)
    3. You would need to update the story's variables (there is no documented way to do this) from storage after the reload is finished.

    But maybe someone else (like the story format's developer) knows of a simpler solution.
Sign In or Register to comment.