How to Create a Codex
Introduction: What is a Codex?
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.
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?
It isn't too hard: all you need are two variables, some scripts and an item to act as the Codex. In order to access the Codex at any time, the player just uses the item that represents the Codex. Set it so when the item is used the player is always moved to the same page.
The two variables to use are:
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 are:
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 (this Codex was on page 10) then LASTPAGE is equal to the current page.
Codex Page Script
|%ISCODEX := 1|
Pretty straight forward. This means that once you have entered the Codex front page, 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 were 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.
- 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 separate 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 executing it on
- You can set certain links within the to only be visable when the player has a certain item, or a variable is a certain number. This can allow you to slowly show the player links throughout the game and makes it seem like they are slowly discovering and recording events or creatures they have found in the codex.
- Obviously you can use this for more than just creatures. It can be used as an advanced journal or history book to explain past events, or it can hold information on different characters, or other things that I can't think of and you can.