I've checked the threads under the Sugarcube 1 tag, to no avail.
I want to set some form of flag when a player visits a location, so that on return he gets a slightly different description.
For instance, on first visit:
A long road, nothing ahead.
Early signs of thirst.
And on the player's return:
A long road, nothing ahead.
How would I do this, please?
Comments
If you plan to have many such passages, using the visited() function is probably the better overall choice. Flags are more flexible, however—for example, you could have a flag for an entire region, rather than simply one passage. Also, flags work within included passages (via the <<display>> macro), while the visited() function may not (depending on what you're trying to do, anyway).
With a $variable flag: And initialize $visitedLongRoad in the StoryInit special passage:
With the visited() function:
Thank you again.
Could it have anything to do with my cache?
I'll try the variable option.
[edit] The variable option works
The above visited() function example should have been:
Alternatively, since you really only want to know if the player has ever been to that passage before, either the lastVisited() function or the state.has() method would be ever so slightly more efficient (though it's unlikely to be noticeable in practice). The reason being is that they return as soon as they find an instance of the passage with the history, while visited() iterates over the entire history counting every instance of the passage within the history.
With the lastVisited() function:
With the state.has() method: