That leaves me with the other method. Here is the code I came up with:
verb "ask", "question", "consult"The downside of the above is that you have to predict proper error messages for every case (it's conceivable that there are times where "That doesn't make any sense." doesn't cut it). Just the same, I was pleased that this worked at all.
* (LivingAsk) "about" "his"/"her"/"its" anything DoAsk
routine LivingAsk(var)
{
if var is not living
{
"That doesn't make any sense."
return false
}
local i
for (i = 2;i < words ;i++ )
{
if word[i] = "about"
break
}
local a
select word[(i + 1)]
case "his" : a = "he"
case "her" : a = "she"
case "its" : a = "it"
if var.pronoun ~= a or not Contains(var,xobject)
{
"That doesn't make any sense."
return false
}
else
return true
}
Anyhow, drumroll, please...
The easiest, simplest way to support >ASK CHARACTER ABOUT HIS POSSESSION
Just add this line to your code:removal "his","her","its","your"("Your" because we also want to accept, CHARACTER, GIVE ME YOUR POSSESSION)
Just ignoring these words completely will largely support our cause, I figure. It is more likely that the player will only use these words in instances where they make sense, then they are likely to type, ASK YOUR CHARACTER HIS ABOUT HER ITS POSSESSION (which will still be processed, using the removal method).
So, yeah, that'll make your game sound smarter. Otherwise, you could always mix-and-match between these two methods to make your game seem as smart as possible (I'd probably always declare "your" as a removal, as code that only applies to order_response's seems like it'd be a pain in the ass), and there's plenty of room for improvement with the routine-grammar-token route (for instance, you could have it rely on an ownership system that is unaffected by actual possession).