Hey,
I have a link to my stats page in my header, and a return button on my stats page to go to the last page. However, the problem is that if you click Stats in the header twice, the return doesn't work as it just takes you back to the stats page.
I'm looking for a way to disable the "stats" button when you're on the stats page, but the only thing that happens is that it makes my header completely blank. Otherwise, a way to disable the header or not add the stats page to the history would also work I think.
Here is the code for my header:
{
(if: $stats is false)[[[Stats|Stats]]]
(else-if: $stats is true)[Stats]
}
And here is the code for my stats page:
{
(set: $return to "(link-goto: \"Return\", (history:)'s last)")
(set: $stats to true)
}
All other pages I have this at the top
{
(set: $stats to false)
}
Comments
First page of my story's code:
Header's code:
Stats page code:
I figured out why my previous setup didn't work: $stats wasn't set to false until you clicked a button, so the header was missing from my first page. Then, when you went into the Stats menu, the $stats didn't set to true until you actually clicked Return or the Stats button again.
I fixed the issue by making the actual mouse button click on the Stats button set it to $stats true, and making the $return set $stats back to false.
Try either of the following, they produce the same outcome: ... or:
Is there a way to get around the "(history:)'s last" limitation? E.g. If somebody presses Stats and then Inventory, pressing back would only take them back to Stats and not to the proper passage they were at. My current work around is to disable both buttons when you're in either page, but I'd like to enable them again.
1. Assign each of your menu related passages (Stats, Inventory, etc) a known tag, this example will use menu.
2. Create a variable in your startup tagged passage to track the name of the last non menu tagged passage shown to the reader. This example is using a variable named $last 3. Create a header tagged passage which is going to be used to update the $last variable with the name of the current passage if it is not tagged with menu.
The name of the header tagged passage can be anything you want but you will need to remember the name because it will be used in a CSS selector later. This example is naming the header tagged passage Passage Tracker and it contains the following code: 4. Add a Back link to each of the menu tagged passages which uses the $last variable, the Link Text of the link can be something other than Back. 5. Use CSS to hide the contents of the header tagged passage created in step 3, the CSS selector needs to contain the name (title) of the passage. If you named your passage something other than Passage Tracker then you need to change the title part of the CSS selector.
E.g.
If you go into the Stats menu and then back out, (set: $DEX to $DEX + 10) happens twice.
This is what I'm thinking of doing:
That is a lot of code I have to go back and change if I'm going to use this method, but it's the only solution I can think of.
Your solution is checking to see if the $passagename variable is equal to a number and then assigning a boolean value to it, thus changing the data type of the variable. This is generally not a good idea.
I didn't mean it changes in the stats page, I meant it changes on any other page that has a (set:) function.
Also the reason I have $passagename set to a number and not to false is because otherwise I would need to define $passagename as false for every single passage I have, whereas the first time it encounters it it's default value is 0 (since I haven't defined it yet, and haven't given it a true or false value).
For example, say that the following code is for a passage called "ExitBar", I'd use this code:
I can't think of another way to make sure (set:) functions don't trigger twice, and I really don't want to define every single passage name as false at the beginning of my game.
Edit: I just had somewhat of an epiphany: would it be possible to use (history)'s last and a menu tag to make sure that (set:) functions don't trigger more than once? Something like:
I'm currently heading to bed so I don't know if this code will work or not, but I'll test it in the morning/wait for feedback (whichever comes first), and I'm not sure if (if: not ((history)'s last tags contains "menu")) is a valid argument.
The code you've got there won't work since (history:)'s last just returns the name of the last passage, not a datamap (plus there's some punctuation missing). A working version would be
Note this code won't work on the very first passage, when (history:) is empty.
Though a simpler way might be to just check the history to see if the player has visited the passage before.
That would mean I have to assign a default value to every single passage though, which would end up being hundreds of lines of code in the end. Just the character creation and backend passages alone are over 50 passages long, and I'm only about halfway done with it.
Thanks, this is very helpful!