How to increase a variable only once in a passage, even if visited again?

Twine Version: 2
Story Format: Harlowe

What is the best way to have a variable update only once when you visit a passage lets call it B. I have a inventory link in a footer which if the player visits a passage B that is only suppose to be visited once, which increases a variable. They could cheat by going from this passage to the inventory passage, where there is a BACK link to B that variable will increase and keep increasing if the player visits the inventory and goes back and rinse and repeat.

So i was wondering what is the most simple solution to this problem?

Generally the best way to show additional content without using a Passage Transition is to use a Dialog Box…
(example written in TWEE Notation)

:: Story Footer [footer]
(link-repeat: "Inventory")[
	(dialog: (passage: "Inventory")'s source, "Close")
]

:: Inventory
Code used to show the inventory.

…however Harlowe has limited support for Dialog Boxes.

There are a number of ways to limit the re-execution of code within a Passage, one of the simplest is to track how many times that Passage has been visited, which you can use the special visits variable to do.

(if: visits is 1)[
	This content is only processed the first time this Passage is visited...
]

Does your Inventory Passage update Story Variables? If not then you may want to change your “Back” link to use the (undo:) macro, instead of moving the end-user forward in time to the previously visited Passage.

The content of the Inventory Passage...

(link: "BACK")[
	(undo:)
]

You stated the Inventory Passage has a link that forwards the end-user to the Passage they were viewing just before they visited the Inventory Passage. If the Inventory

Regarding the topic of adding counter measures to your project to stop the end-user from “cheating”…

Because Twine generates a HTML file the end-user has total access to the source code of your project, it is a fairly trivial task for anyone with the most basic of web developer knowledge to circumvent any such counter measures.

Generally the only people such counter measures inconveniences is the people who aren’t cheating, because:

  1. The counter measures code serves no useful purpose for those not “cheating”, and the execution of that code slows down the processing of the current Passage (and any child content it references).
  2. Adding such counter measures takes time, which delays an Author’s progress in creating the other content of the project.

Thanks for your help. No my inventory doesn’t update any story variables.

I ended up doing it like this, leaving your comment in there as a reminder in the future. Works great.

{(text-colour:red)+(if: visits is 1)[+1 Paranoia (set: $Paranoia to $Paranoia +1)<!--This content is only processed the first time this Passage is visited...-->]}