My new, much better, and working (i think) solution.
-
Add a “menu” tag to each MENU/INVENTORY passage.
-
Add a link to inventory/menu at header.
Place this code in vars section:config.header.center :"{link to: Inventory, label: 'Inventory'}"
-
Paste this code in JavaScript section of story
comesFromMenu = function (){
if (trail.length>1){
if (engine.story.passageNamed(trail[trail.length-2]).tags.includes("menu")){
return true;
}else{
return false;
}
} else {
return undefined;
}
};
get_last_ingame_passage =function(){
let trail_clone=Object.assign([],trail);
let rtrail=trail_clone.reverse();
let result = rtrail.find(el => !engine.story.passageNamed(el).tags.includes("menu"));
return result;
}
- At the bottom of the inventory/menu, or wherein you want to insert your link back to ingame, paste the following:
[JavaScript]
engine.state.set("last_ingame_passage",get_last_ingame_passage());
[continue]
{link to: last_ingame_passage, label: 'Continue'}
- UPDATE:
In order to avoid (for example) the same vars been incremented again when you return from the inventory/menu passage/s to the last ingame passage, you must express that condition at vars section:
strength (comesFromMenu() != true): strength+ 1
You can also perform those operations inside a javascript tag in any passage:
[JavaScript]
if (!comesFromMenu()) {
strength = strength +1;
}
[continue]