Howdy, Stranger!

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

Changing text every few visits.

Hello all, first time poster here. Been doing some stuff with Twine last couple of months and learning the basics. I have something here that looks like I'm stepping firmly out of 'the basics' though.

The basic idea is that I'm doing a horror story where I want a section of text to change every couple of times they visit the room. There is a qualifier of the player need to reveal the item in question, but that's working fine. The issue I'm getting is finding some way of replacing this section of text in a progressive manor rather than randomly with an (either:) command.

So far the code I have looks something like:
(if: (History:) contains "qualifying passage)[(if: count ((History:), "current passage") >=1)[First text](elseif: count ((History:), "current passage") >=3)[Second text](elseif: count ((History:), "current passage") >=5)[Third text](elseif: count ((History:), "current passage") >=7)[Forth text](elseif: count ((History:), "current passage") >=9)[Final text]]

Now the problem is this way around, it never moves off the first round of text. I'm dried doing it the other way around with <= but then of course they all display at once.

Not quite sure where I can go from here.

Comments

  • edited September 2015
    The problem is the >= 1 test will always be true, which means that the later tests don't ever get checked. One way to fix it would be to reverse the order of the checks:
    (if: (History:) contains "qualifying passage)[
    (if: count ((History:), "current passage") >=9)[Final text]
    (elseif: count ((History:), "current passage") >=7)[Forth text]
    (elseif: count ((History:), "current passage") >=5)[Third text]
    (elseif: count ((History:), "current passage") >=3)[Second text]
    (elseif: count ((History:), "current passage") >=1)[First text]]
    

    Also I'd recommend storing the 'count ((History:), "current passage")' part in a variable so you don't need to keep typing it out.
  • It is easier to use a $variable to track how many times something has happen that it is to use the (history:) macro, it is also faster as checking the (history:) macro's contents takes longer the more passages the Reader has seen.

    note: A startup passage is where you should be initializing (giving a default value) to the $variables used in your story, it is a standard passage that has a startup tag.

    In your startup passage initial a counter to zero, you can call the counter whatever you like but I am going to call it $counter for convenience.
    (set: $counter to 0)
    
    In the passage with the conditional text:
    (if: (History:) contains "qualifying passage")[
    (set: $counter to it + 1)
    (if: $counter < 3)[First text]
    (else-if: $counter < 5)[Second text]
    (else-if: $counter < 7)[Third text]
    (else-if: $counter < 9)[Forth text]
    (else:)[Final text]
    ]
    
    note:
    a. I added extra line breaks to make the example easier to read, you can remove them.
    b. As this passage will be seen many times you may want to also replace the (History:) contains "qualifying passage" check with a true/false $variable.
  • Thanks, that got it sorted... combination of setting up the $variable in a startup passage and setting them up in a reverse order >= check got it working.
  • .. setting them up in a reverse order >= check got it working.
    You shouldn't of needed to set them up in the reverse order if you used the < comparison I had in my example.
Sign In or Register to comment.