I’m having a problem with referring to a table in this game where I’m trying to define a number of NPCs using a table. I’ve gotten them to generate the npcs, but I can’t get a similar item (which uses the same table) to list the npcs in a comprehensive list.
This is the tip of the ice-burg with this table I feel… but here is the code I’m working on:
Gender is a kind of value. The genders are masculine, feminine, and unknown. Understand "male" or "man" or "M" as masculine. Understand "female" or "woman" or "F" as feminine. A person has a gender.
A schoolhouse is a kind of value. A person usually has a schoolhouse. The schoolhouses are Gryffindor, Ravenclaw, Hufflepuff, Slytherin and Unsorted. A person is usually Unsorted.
A student is a kind of person.
The Great Hall is a room.
Some students in the great hall are defined by Table 1.
A person has some text called their Forename. A person has some text called their Surname.
[A quick search of the forum has given me this function:]
To say ordinalize (N - a number):
let the last digit be the remainder after dividing N by 10;
if the last digit is 1:
say "[N]st";
else if the last digit is 2:
say "[N]nd";
else if the last digit is 3:
say "[N]rd";
else:
say "[N]th";
[the table does have rows!]
Table 1 - Classmates
student Forename Surname Gender Year schoolhouse
s1 "Ben" "Robbins" masculine 2 Gryffindor
s2 "Kristopher" "Franklin" masculine 1 Slytherin
s3 "Kyle" "Summers" masculine 3 Gryffindor
s4 "Gerardo" "Robinson" masculine 7 Hufflepuff
The description of a student is "[Forename] [Surname], a [ordinalize the year] year [schoolhouse]."
The initial appearance of a student is "[Surname], a [ordinalize the year] year [Schoolhouse] is nearby."
[Understand a noun's surname as the noun.]
To list the Slist:
say "The student list runs as follows..";
repeat through Table 1:
say "[Surname], [Forename] - [schoolhouse]-[Year]".
The roster is a thing in the great hall.
Instead of examining the roster:
list the Slist.
Listing the Slist is the thing I’m struggling with, where it just gives me .-Gryffindor-0 four times.
I’d also like to see if anyone has any feedback on how I can refer to these guys using their “forename” or “surname” properties, but thats later.
This code should work all by itself.