+3 votes
by (2k points)
So i'm using this method http://twinery.org/questions/1854/sugarcube-more-problems-with-game-returning-from-menu-solved?show=1854#q1854 to go to a passage menú and returning from it. But whenever I do, the macros that already have taken actions take action once more. What can I do to solve this situation?

1 Answer

+2 votes
by (41.9k points)
selected by
 
Best answer

Ah, yeah, that can be a problem with that method.

The simplest way to fix that is to first add something like the following to your JavaScript section:

// Fresh is true if you didn't come from a passage with a "menu" tag
window.Fresh = function () {
	return !tags(previous()).includes('menu');
};

Next, just wrap any code which triggers macros or code that you don't want re-triggered when you come back to the passage inside the following code:

<<if Fresh()>>(code you want to only trigger once)<</if>>

Now that code will only get triggered if you come from a passage that doesn't have a "menu" tag.  This will likely require modifying multiple passages, but I don't think that there's a solution which doesn't require that.

Hope that helps!  :-)

by (2k points)
Thank you veeeeery much. Merry Christmas.
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...