So I have the action SetTo being called, which has the following rule:
'set' singleDobj 'to' literalIobj
Is there a way of taking the content of literalIobj and trying to match it to an iobj?
Like, if the literalIobj contained the token “station”, could I replace it with another action,
and attempt to find an iobj which has a vocab match for “station”?
Hypothetically, like so:
// These methods are all fictional, btw
local literalTokens = getTokensFromLiteral(gLiteralIobj);
doInstead(OtherActionName, gDobj, gIobj);
One brute force way of doing it would be to use gLiteral (the string value of the literalIobj) to construct a new command and then force the parser to parse (and run) the new command, e.g., the following would take a command like SET WIDGET TO FOO and turn it into PUT WIDGET ON FOO:
A more rigorous alternative would be to define a TopicTAction version of SetTo with the appropriate grammar (using topicIobj in place of literalIobj in the corresponding verbRule) and then inspecting the value of gTopicMatch to see if it’s a Thing or a Topic. If it turns out to be a Thing you could then use:
doInstead(OtherActionName, gDobj, gTopicMatch);
/* Do something with gTopicText, the text entered by the player */