if player’s command includes “[any thing]”
you can determine if objects are present in the player’s command and of course extract the matching word or words, but how do I determine which object has been matched to this text? Surely Inform must have a reference to the object associated with the matching text, something like “matched thing”, corresponding to “matched text”.
BTW, at the moment to get around this apparent limitation, I have set up a table of every object in the game together with each object’s grammer, and have then made a loop checking each object’s grammar with the player’s command for a match. If match is found, then of course I now know the corresponding object.
Although this works nicely, it seems inefficient (memory-wise, and perhaps speed-wise too) to essentially store the grammar in a separate table when the built in parser must be doing the same.
Why are you checking the player’s command for [any thing] in the first place? There might be an easier way to achieve the same end.
I’ve created an ambitious conversation and action system whereby objects / topics can be asked about to one or more person in the same command, in a much more flexible way that just “ask bob about the hat”, e.g.
“> jim, dan and fred, could you help me reach the brass lamp on the roof of bob’s hideout?”
“> steve, how tall would you say jim is?”
“> jim and dan, when i say now, go to the hilltop then wait for me”
“> say now”
For (2), this is just action based stuff with some modifications to deal with addressing multiple npcs (so I need to determine all objects up to the first non-object).
For (1) I have set up flexible grammar statements: e.g.
Understand "could you help me", "would you mind helping me" as [G-ask-for-help]"
Understand "to/-- reach/get/obtain" as "[G-to-get]".
Understand "[G-ask-for-help] [G-to-get] [G-OBJECT] on the/-- [G-OBJECT] of [G-OBJECT] [G-OBJECT]" as "[G-asking-for-help-reaching-something-on-someones-something]".
where [G-OBJECT] isn’t just limited to a single object, and can be a possessive noun also. The conversation system has a rule that then reads the object list understood in the grammar statement and gives an appropriate response.
So basically for (2), I need to be able to parse for objects in player’s command / topic understood once the typed command falls through to “answering someone that”.
I have all the mechanics of this working correctly, currently without any I6 hacks, but going back to my original question, I am wondering whether I can grab an object list from the typed command via the build in parser routines already, without having to duplicate information and store a seperate table for all the objects / grammar in my code.
I can’t think of a good way to do this without I6 hacks. You might look at the extension Multiple Actors, which modifies the I6 parser to accept commands like ALICE, BOB, AND CLAIRE, GO TO THE LIBRARY.
If you want to parse for a list of objects in a grammar line, you can use the [things] token (which will put the list of things found into the “multiple object list”). For possessives, there’s an extension called Possession and Ownership by Shadow Wolf (which I cannot seem to find anywhere at the moment…) to handle that aspect automatically.