The title of this post is what I think my problem is (the need to provide tables that vary) while the remainder is the context for the problem (I need tables to hold page contents from books).
I’ve been looking at Example 303 (Pages) and it’s helpful to get started but it’s trickier when you might have multiple books to consult. I think I’ve generalized the example a bit, which I’ll show here, but I’m stuck when it comes to the table part.
For example, I have this:
A codex is a kind of thing. A codex called the Brief History of Magic is carried by the player. A codex called the prophecy is carried by the player. Reading it in is an action applying to one number and one thing, requiring light. Understand "read [number] in/from/of [something]" as reading it in. Understand "read page [number] in/from/of [something]" as reading it in.
So I have two things that can be consulted by page number. Given that I now have to modify the example from 303 a bit as such:
Check reading it in: if the second noun is not the prophecy or the second noun is not Brief History of Magic: say "There are no pages in [the second noun]." instead. Check reading it in: if the number understood is greater than the length of the second noun: say "There are only [length of the second noun in words] pages in the codex." instead; if the number understood is less than 1: say "You might just want to start on the first page." instead. Carry out reading it in: read page number understood.
I think those parts are probably okay. Where I run into trouble is with the table part. I need to have two separate tables that are consulted. So I need that “read page number” part to be something like this:
To read page (N - a number): let the text source be the second noun; now the last page read of the text source is N; if the text source is Brief History of Magic: let the table source be the Table of Brief History Contents; if the text source is the prophecy: let the table source be the Table of Codex Contents; if there is a content corresponding to a page of N in the table source: choose row with a page of N in the table source; say "You read:[paragraph break][italic type]'[content entry]'[roman type][paragraph break]"; otherwise: say "Page [N] appears to be blank."
This doesn’t work. I get the error:
You wrote ‘let the table source be the Table of Brief History Contents’ , but when a temporary value is created inside an ‘if …, …’ or an ‘otherwise …’, it only lasts until that line is complete - which means it can never be used for anything, because it goes away as soon as created. To make something more durable, create it before the ‘if’ or ‘otherwise’.
What I’m doing different from the example is with those
let phrases in that I’m trying to provide a different table as part of the processing depending on what the second noun was.
read page 2 of the prophecy
read page 2 of Brief History of Magic
But I can’t follow the advice given in the error message because creating it before the
if condition would make no sense. The whole point is for the table to reference to change based on a condition. I did try adding a line at the top of the rule as such:
let the table source be a table that varies;
But that also doesn’t work. The error is:
In the sentence ‘let the table source be a table that varies’ , I was expecting to read a value, but instead found some text that I couldn’t understand - ‘a table that varies’.
I’ve tortured this explanation to death to show my steps along the way in case I’m either (1) approach the problem poorly or (2) screwing up an obvious bit of implementation.