Hi, I’m new to Inform 7 (but an experienced programmer in many other lanugages), and I have a particular use of the parser that I want to try out. I’ve looked for extensions/information on this and I can’t find anything so I’m not sure if it will be possible.
I want to be able to answer parser queries about properties. For example “what colour is the turtle”, “what size is the dog” (forgoing for now whether this is a good idea or not game wise…).
The closest I’ve got is providing Understanding clauses for individual properties, e.g.
[code]Color is a kind of value. A thing has a color. The colors are red, blue, and black and neutral. A thing is usually neutral.
Whatiscoloring is an action applying to one visible thing.
Report whatiscoloring something:
say “[The noun] is [color of noun].”
Understand “what color is [something]” as whatiscoloring.
Size is a kind of value. A thing has a size. The sizes are tiny, small, large, big and huge. A thing is usually small.
Whatissizing is an action applying to one visible thing.
Report whatissizing something:
say “[The noun] is [size of noun].”
Understand “what size is [something]” as whatissizing.[/code]
I don’t really like this approach aesthetically/elegance-wise, but also I have to repeat the code for each property. I’m wanting to do if anyone can find a way I can generically write rules to parse the user input of specific property names like “color” or “size”. The issue is that these are names of kinds, not adjective properties so I don’t think I can parse them.
Here’s my ignorance-fueled idea of how it might look:
Whatis is an action applying to one kind of property and one thing.
Report whatis something:
say "[The noun] is [property of noun]."
Understand "what [property] is [something]" as whatising.
So anyone have any ideas that are nicer than the first implementation above?