Hi everyone, I posted this on the if newsgroup but that doesn’t seem to be very active. Hoping I can get some help from here! Here’s a copy of my question:
Hi, I am beginning inform 7 and I have a question. I have tried
multiple ways to attack this problem but I always get some sort of
Say for example I am trying to create a book. I want each book to have
an appendix. That’s fine. But if I then want each appendix to have
properties (like a first entry and a last entry) how do I deal with
this? I could have the book have just a first entry and a last entry
but I want the code to represent the hierarchy, as well as perhaps use
the same appendix object for other items. I tried making an appendix a
part of every book, but then I didn’t know how to over-ride features -
such as if I wanted the last entry to be “u” instead of “z”. When I
just said that books have an appendix called index, the compiler
complained about there being no appendix in the world. I even tried
making a “default” appendix for it to set to but it didn’t like that
either. What is the right way to assign and access properties and
values embedded in objects like this?
The book example is just an example - I am working with something that
has a highly hierarchical structure and it would get clumsy after a
while to just put everything on the “book” thing.
I saw your post on raif, but didn’t answer since I’m not sure I quite get what you’re looking for. It would be easier if you posted some sample code of yours (even the stuff that didn’t work) or a sample desired transcript, so we could get a better idea.
When you create a new kind, you create default values for any properties you give it, which can be over-ridden. Maybe something like this?[code]A book is a kind of thing.
An appendix is a kind of thing. An appendix is a part of every book.
An appendix has some text called first entry. The first entry is usually “Default first entry”.
An appendix has some text called last entry. The last entry is usually “Default last entry”.
Instead of examining an appendix:
say “The first entry reads: ‘[first entry of the noun].’”;
say “The final entry reads: ‘[last entry of the noun].’”.
The Lab is a room.
The generic book is a book in the Lab.
The diary is a book in the Lab. The first entry of the Diary’s appendix is “List of Accomplishments”. The last entry of the Diary’s appendix is “I give up”.
test me with “read appendix / generic / read diary’s appendix”.[/code]
This technique should work as well, depending on how you implemented it. Without seeing your code, I have no idea why it didn’t.
Unfortunately, the book example might be leading me down the wrong path. Does the structure you’re trying to model involve actual components, layers of text objects, or just properties you want to be able to tack onto parent objects in groups? Does that make sense?
That is exactly what I was looking for! I am so sorry, it seems that I did get it, but was experiencing a whole other problem. I guess I still have kinds mixed up. For example I have problems when I try this:
A red book is a kind of book. The first entry of the red book's appendix is usually "Hello".
I get : Problem. You wrote ‘The first entry of the red book’s appendix is usually “Hello”’ : but the property first entry for the red book’s appendix is not allowed to exist, because you haven’t said it is. What properties something can have depends on what kind of thing it is: see the Index for details.
If a red book is a kind of book, it should have an appendix too, shouldn’t it?
I’d love to tell you about what I’m working on, but I’m afraid it would confuse you. I hardly understand it! I’m trying to model a system to see if I can do it in Inform and learn it along the way. I’ll choose my analogies carefully though
Ok again I solved my own problem. I am getting kinds and objects mixed up - the proper thing shoudl have been “the first entry of the appendix”.