Howdy, Stranger!

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

How do I make a passage visible only once ever per reader/cookie?

Sup guys, new to Twine/Harlowe here.

I want to have a passage that's only possible to look at once ever per reader. It's supposed to be like an "instructions manual" and at the same time, it adds stats to, say, 4 different things.. Like so:
(set: $candyce +50)
(set: $max +50)
(set: $steven +50)
Now I don't want the reader to be able to come back and reheat the page to farm stat points for the characters. How do I go about making it impossible to do so?

Comments

  • The (set:) macros in your example are invalid, the documentation contains examples of both assignment and addition:
    ''Assignment''
    (set: $candyce to 50)
    (set: $max to 50)
    (set: $steven to 50)
    
    ''Addition''
    (set: $candyce to it + 50)
    (set: $max to it + 50)
    (set: $steven to it + 50)
    

    If the Reader refreshes the web-browser page the story will restart from the beginning.

    You control which links navigate to the 'instructions manual', so if there is only a single link to that passage and if that link is only shown to the Reader once, then the Reader can only navigate to that passage once.

    If for some reason you want the Reader to be able to navigate to that passage multiple times then you can use another (Boolean) variable to gate the additions like so.

    1. In your startup tagged passage initialise the Boolean variable, you should also initialise your other variables to their default values.
    (set: $firstTime to true)
    
    (set: $candyce to 0)
    (set: $max to 0)
    (set: $steven to 0)
    

    2. In the 'instructions manual' passage check the $firstTime variable and execute the Additions if needed.
    (if: $firstTime)[
    	(set: $firstTime to false)
    	(set: $candyce to it + 50)
    	(set: $max to it + 50)
    	(set: $steven to it + 50)
    ]
    
    note: the above example contains indentation and extra line-breaks, these can be safely removed.
  • edited June 2016
    Does the startup tagged passage require opening before it runs or can it be placed somewhere without any links to/from it and it'll still apply the stats once per refresh? Also, lost on the use of the if command. If first time what? It's already true in the startup..
  • As explained in the documentation, startup tagged passage(s) are automatically processed before the first passage shown in your story.

    The (if:) macro checks if the supplied Boolean data expression equals true or false.

    If the variable being evaluated contains a Boolean value then you don't need to compare the variable against another value like you do with other data types.

    e.g 1. Boolean variable is equal to true
    (if: $booleanVariable)[]
    
    is the same as
    
    (if: $booleanVariable is true)[]
    
    e.g 2. Boolean variable is equal to false
    (if: not $booleanVariable)[]
    
    is the same as
    
    (if: $booleanVariable is false)[]
    
Sign In or Register to comment.