Howdy, Stranger!

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

Change room description after visit another room.

I think I need to set a variable of "visited" to be set to "true" after I visit another room, but I don't understand how to set this or how to get the descriptions in two other rooms to be changed after this variable is set.

Sorry, new to this and using 2.0.11 and harlow.

Comments

  • Am I understanding this correct
    At the start I set
    (set: $counter to 0)
    

    Then in each of my rooms that need changing I use?
    (if: (History:) contains "qualifying passage")[
    (if: $counter = 0)[This should be my default text for a room]
    (else-if: $counter = 1)[This is my replacement text]
    
    ]
    

    Then when the player gets to the location I need I use?
    (set: $counter to it + 1)
    
  • Does the room's description change:

    a. Only once, after the first visit to the "qualifying passage" by the Reader.

    In this case you only need the (history:) check.
    (if: not ((history:) contains "qualifying passage"))[
    The passage's original description....
    ](else:)[
    The passage's replacement description.....
    ]
    

    b. Multiple times, after each visit to the "qualifying passage" by the Reader.

    In this case you will need to track how many times the Reader has visited the "qualifying passage". One way you can do this is to use the (count:) macro to determine how many times the "qualifying passage" appears in the array returned by the (history:) macro.
    (set: $count to (count: (History:), "qualifying passage"))
    (if: $count is 0)[
    The passage's original description....
    ](else-if: $count is 1)[
    The passage's first replacement description, it appears after the Reader first visit to the "qualifying passage"
    ](else-if: $count is 2)[
    The passage's second replacement description, it appears after the Reader second visit to the "qualifying passage"
    ](else:)[
    The passage's third replacement description, it appears after the Reader has visit the "qualifying passage" three or more time.
    ]
    

    warning: The array returned by (history:) gets larger each time the Reader navigates from one Passage to another, this causes things like contains and (count:) to take slightly longer to determine their result each time the array grows.
    Eventually this delay may become noticeable by the Reader, if this occurs then you may wish to replace both A and B with a solution like the following that uses a variable instead.

    1. Initialize the $counter variable.
    I suggest doing this in a startup tagged passage, but you could do it in your story's first passage as long as that passage is not the one you need check the value of $counter in.
    (set: $counter to 0)
    
    2. Increment the $counter variable in the "qualifying passage"
    (set: $counter += 1)
    
    3. Determine what to show based on the $counter variable:

    3a. Only once, after the first visit to the "qualifying passage" by the Reader.
    (if: $counter is 0)[
    The passage's original description....
    ](else:)[
    The passage's replacement description.....
    ]
    
    3b. Multiple times, after each visit to the "qualifying passage" by the Reader.
    (if: $counter is 0)[
    The passage's original description....
    ](else-if: $counter is 1)[
    The passage's first replacement description, it appears after the Reader first visit to the "qualifying passage"
    ](else-if: $counter is 2)[
    The passage's second replacement description, it appears after the Reader second visit to the "qualifying passage"
    ](else:)[
    The passage's third replacement description, it appears after the Reader has visit the "qualifying passage" three or more time.
    ]
    
  • Thanks,
    does both the "+" and "=" have to be present?
    (set: $counter += 1)
    
  • Yes.

    The addition assignment operator (+=) is a short-cut that can be used to replace the standard $variable = $variable + value expression.
    $variable = $variable + value  ==>  $variable += value
    
    There is also a subtraction assignment operator (-=)
    $variable = $variable - value  ==>  $variable -= value
    
  • greyelf wrote: »
    Yes.

    The addition assignment operator (+=) is a short-cut that can be used to replace the standard $variable = $variable + value expression.
    $variable = $variable + value  ==>  $variable += value
    
    There is also a subtraction assignment operator (-=)
    $variable = $variable - value  ==>  $variable -= value
    

    Thank you for explaining that, it works now. just need to work on a score system that will show a different ending based on the score and I am sure that I spotted that answer somewhere.
Sign In or Register to comment.