Saying the kind of a thing

Hello there. Here’s a problem, hopefully with a simple answer I’ve missed.
Say I have a game:

Petting zoo is a room.
Sheep is a kind of animal. Duttur is a sheep in the petting zoo.
Goat is a kind of animal. Baphomet is a goat in the petting zoo.

petting is an action applying to one thing. understand "pet [an animal]" as petting.
carry out petting: say "You pet the [kind of noun]".

Question: How do I get the phrase “kind of noun” to return “sheep” or “goat” etc. I know I could do:

to say kind of (a - an object): if a is a sheep, say "sheep"; if a is a goat, say "goat".

but that’s ugly, and my actual game has loads of kinds, in a hierarchy, and maintaining that routine is getting silly.

Any ideas? :bulb:
(The terms are too generic to effectively Google it…)

Thanks!

The easiest way is to define a property (An animal has some text called kind-name. The kind-name of a sheep is “sheep”. Carry out petting: say “You pet the [kind-name of noun].”)

(previous similar topic: https://intfiction.org/t/printing-names-of-kind/7668/1)

Thanks. Sorry for the duplicate post - as I say, difficult to search for it.

I’ve considered that approach, but it’s still rather kludgy having to define them all, either inline or in a table. There must be a more elegant and programmatic way, even if it means a bit of I6 code.

If my sheep is unnamed (eg. In the petting zoo is a sheep) then say “[the noun]” shows “the sheep”, so kind names are clearly accessible to the interpreter. Really odd there’s no simple way of surfacing them!

There’s some I6 code to do something like that in this post. You could insert that code and then say “type of noun” where you currently have “kind of noun.” It prints with an initial capital for some reason but you could easily write some code to get around that (just define a substitution that prints the type of the noun in lower case). This works in version 6L02 of Inform 7; I haven’t checked in 6L38.

Yeah, I just found that. After playing around and reducing it, turns out this is really simple. Just need:

An object type is a kind of value. To decide what object type is the type of (O - an object): (- ({O}.2) -). To say (T - an object type): (- print (I7_Kind_Name){T}; -).
And now my sample game looks like:

Petting zoo is a room.
a sheep is a kind of animal. the plural of sheep is sheep. Duttur is a sheep in the petting zoo.
a goat is a kind of animal. Baphomet is a goat in the petting zoo.

petting is an action applying to one thing. understand "pet [an animal]" as petting.
carry out petting: say "You pet the [the type of noun]. ".

I also added a property, initialised at play time, which let’s one “pet a/the goat”, even when the goat is properly named:

a thing has a text called kind-name. understand the kind-name property as describing a thing.
when play begins:
	repeat with ob running through things:
		now the kind-name of ob is "[the type of ob]".

The capitalisation emerges however it was used when defining the kind. Not sure how brittle to different versions this might be - I’ve no idea what’s going on in the I6 code - but for now it’s sorted.
:slight_smile:

Still think it should be exposed in I7 though…

Loxlie,

Thanks for posting your solution to this issue. It’s very compact.

FYI - There is an official place to submit feature requests to the authors: inform7.uservoice.com. As an example, I submitted a uservoice suggestion regarding this same feature request:

inform7.uservoice.com/forums/573 … -of-a-kind

Please do add your vote.

Vote added. I like this idea.

Addendum: I’d love it if I7 kinds were first-class citizens in their own right, but I haven’t the faintest how hard that would be to implement. I’m thinking of phrases such as

To say group-description of (K - a kind) inside (R - a container): say "[number of Ks in R in words] [K][s]".

which would, I think, be awesome to be able to do.

I’m not 100% positive this is impossible in regular Inform 7, of course. But as far as I can glean from the manuals, kinds by themselves cannot be passed as parameters in this fashion.