Before I continue…
Dannii is correct and relations would probably help you quite a bit here.
In fact, tying the traits you want to a spell would be rather easy. Like so!
(Ignore my bizarre choice of testing methods with the wait command, ehe.)
…That being said, in the service of the questions about tables you asked I still thought I’d take the time to help you out with your table questions!
Table Stuff
So as Celtic suggested up there, using tables like that typically involves telling Inform to “choose” a row, which then tells it what you mean by “[thing] entry“. Even tying a table name to a thing I’m pretty sure that you still have to do this… otherwise, how would it know which row in the list of rows you’re asking for?
A couple of things here:
- I’m assuming you want to read through the list of spells in a spell book, one after the other. This example otherwise cleaves close to what you gave us, like using text for the lookup (I second Dannii in not recommending this) and the formatting on the say statement.
- You’ll notice that the first example had some formatting on the output and this doesn’t. I’m not sure what your desired behaviour is, but placing your entries within a single “say” statement like I did in the first example might help you out!
- If you aren’t careful you could output absolutely nothing. I’m sure you won’t include any completely empty spell books, but if you would for whatever reason then I recommend putting a condition which reacts to it like I have up there (outputting the “sadly bereft of spells” line). Also a check rule, but again I don’t know what your code looks like outside of the example!
- Side note, but don’t use “number of rows” in your description. That INCLUDES blank rows. Since it’s talking about known spells you want to use “number of filled rows“.
Regarding the inscribing, that’s another reason why going with Dannii’s option might be helpful for you. Messing with tables often involves a lot of choosing rows and seeing if rows are empty and etc. etc. without much wiggle room provided to you by Inform.
That.
Being.
Said.
My Awful Just-Woke-Up Choices
A thing can be readable.
A thing has some text called inscription-text.
A spell book is a kind of readable thing.
A spell book has a table name called known spells.
The known spells of a spell book is usually the Table of Learned Spells.
Description of spell book is "A thick tome for recording all the spells you know. Its title letters almost glow. Currently, it contains only [number of filled rows in Table of Learned Spells], but has many pages for new spells to be learned. Of course, you will need magic ink to add more spells to your spell book.".
A spell is a kind of value. The spells are the First Testing Spell and the Second Testing Spell.
Table of Learned Spells
Name (a spell) Cost (number) Notes (text)
First testing spell 1 "This is just for testing!"
with 39 blank rows
Table of Also Learned Spells
Name (a spell) Cost (number) Notes (text)
Second testing spell 20 "This is also just for testing!"
with 39 blank rows
[==========]
Reading is an action applying to one thing. Understand "read [a spell book]" as reading.
[^By default "read [something]" feeds into the examine action, so my personal recommendation would be to remove that from it. For the purposes of not getting into that now, I have specified that this takes a spell book so that the command parses to this action instead.]
Check reading:
if the noun is not readable:
say "[We] [cannot] read that.";
stop the action;
[^A spell book will always be readable but once again, usually this would accept more than spellbooks.]
Carry out reading:
if the noun is a spell book:
if the number of filled rows in the known spells of the noun is greater than 0:
repeat through the known spells of the noun:
say "[bold type][Name entry] ([cost entry]):[roman type] [notes entry][line break]";
otherwise:
say "[The noun] [are] sadly bereft of spells.";
otherwise:
say "[inscription-text of noun]";
[==========]
Inscribing it in is an action applying to two things. Understand "inscribe [something] in/into [something]" as inscribing it in.
Check inscribing it in:
if the second noun is not a spell book:
say "[The second noun] [aren't] very receptive to spells.";
stop the action;
Check inscribing it in:
if the noun is not a spell book:
say "[The noun] [aren't] much help.";
stop the action;
Check inscribing it in:
if the number of filled rows in the known spells of the noun is 0:
say "[The noun] [aren't] much help, empty as [they] [are].";
stop the action;
Check inscribing it in:
if the number of blank rows in the known spells of the second noun is 0:
say "[The second noun] [may] hold no more spells.";
stop the action;
[^You should definitely name all of these check rules, and in fact all of the rules you create. But I'm a touch exhausted right now and this works in the meantime.]
[These checks basically see if either of these aren't a valid source of spells, then if the noun has spells to give or the second noun can even take any. Basic stuff.]
Carry out inscribing it in:
let inscribing-count be a number;
repeat through the known spells of the noun:
if there is a name of name entry in the known spells of the second noun:
do nothing; [Sadly "if there is not a name" doesn't work. We don't want to write duplicate spells, though. Hence the check.]
otherwise:
let name-item be the name entry;
let cost-item be the cost entry;
let notes-item be the notes entry;
choose a blank row in the known spells of the second noun; [We saved all of those values as temporary variables before because I'm pretty sure the moment we choose this new row to write to we wouldn't be able to directly reference the row-to-write in the table anymore!]
now the name entry is the name-item;
now the cost entry is the cost-item;
now the notes entry is the notes-item;
increment inscribing-count; [We use this to keep track of how many spells have been inscribed... as well as whether any have, at all!]
if the number of blank rows in the known spells of the second noun is 0:
say "[The second noun] [have] no more space after adding [name-item].";
break;
if inscribing-count is 0:
say "Hmm! [The noun] [have] nothing to offer [the second noun]."; [This could have been a check rule, certainly, but I didn't like the idea of running through the tables to compare them twice when I could try being more efficient.]
otherwise:
say "[The second noun] thrums with [inscribing-count] new [if inscribing-count is 1]spell[otherwise]spells[end if]!"; [Thrums should be a verb substitution situation but let's not get into defining those now.]
[==========]
The Garden is a room.
The test spell book is a spell book in the garden.
The helpful transfer grimoire is a spell book in the garden. The known spells of the helpful transfer grimoire is the Table of Also Learned Spells.
Running this code, we can see the results are…
So what (I think) you want is definitely doable! And semi-reasonably! But once again: you’ll notice all of the extra work I had to do to keep everything nice and orderly and not potentially throwing errors. (Case in point: I accidentally swapped “noun” and “second noun” somewhere when writing this and it was… just absolute chaos.)
I hope all of this helps in some way! And feel free to ask any followup questions. Apologies if I made any weird choices/errors in this or if I failed to explain something adequately. I’m exhausted from my own endeavors.