Well I'm making a codex in my newest game, so I decided to share how it's done. It's nothing impressive, but I figured I would post how to do it in-case someone else wants to at some point.
What is a Codex?
In my story, the codex is a page with a list of entrees of different creatures. Each creature has it's own page dedicated to it, and the page always links back to the codex. The key thing about the codex, is that it's accessed through an item and as such can be used at any time in the story.
So in abstract form, it looks like this:
Any Page <------> Codex <------> Any Creature Entry
You can't view any creature entry without first going to the codex, and you can only go back to the story through the codex.
How do you do it?
Well it wasn't too hard, all you need are two variables, and some scripts.
The two variables I used were:
ISCODEX - Used to determine if the current page is within the codex (Is either 0 or 1)
LASTPAGE - Used to determine the page you came from when you entered the codex (Is any number)
The Scripts were:
Global Page Script
IF %ISCODEX = 0 AND $PAGEID != 10 THEN
%LASTPAGE := $PAGEID |
What this is saying is that, so long as the current page isn't within the codex, and is not the codex page (my codex was on page 10) then LASTPAGE is equal to the current page.
Codex Page Script
Pretty straight forward. This means that from now on any link you go to is within the codex and will not be saved as %LASTPAGE.
Codex Page - Return to Story Link
$DEST := "@P" + %LASTPAGE
%ISCODEX := 0 |
This is the scripting in the link on the codex page, which will take you back to where you where in the story. The first line is setting the destination of the link to whatever the %LASTPAGE variable is, the "@P" is just syntax that the site uses for page numbers. The next line sets the ISCODEX variable back to zero, since you're leaving the Codex and going back to the story.
Additional notes
You can set the "Return to Story" link on the "Codex" page to anything, i just set it to link back to the Codex page. It doesn't matter what you set it to since the destination will be changed by the script.
It works with multiple chapters. I have my codex and all it's entrees in it's own seperate chapter to organize things. Since it links directly to the page number there are no issues with moving between chapters. By this I mean the Codex page can be accessed by, and move back to, pages within different chapters.
We need the additional ($PAGEID != 10) check in the global page script because when you enter the Codex page, the global script would run before the page script. This means that it's checking the Codex variable before we change it. We could make the change in the global variable, but since we only need to change it on the one page, there is no point in exceuting it on