Text Capture
version 6 by Eric Eve
Example: * Intelligent Putting - Using text capture to improve implicit take messages.
It generally makes for smoother game-play if commands like PUT BALL IN BOX or PUT BOX ON TABLE perform an implicit take when the object to be put somewhere isn't already held. We generally do this by saying "(first taking the whatever)" and then using 'silently try taking the whatever' to attempt the implicit take.
If, however, the attempted take doesn't succeed (perhaps because the object we're trying to take is fixed in place), then a message like "(first taking the whatever)" is a little misleading, since we have not in fact taken the object in question, we have merely attempted to do so. In this situation "(first trying to take the whatever)" would be more appropriate. The difficulty is that we don't know whether 'silently try taking the whatever' will succeed until we try it, so we don't know whether we want "first taking..." or "first trying to take..." until we've tried to take the object and maybe seen a message explaining why we can't; but we'd then want "(first trying to take the whatever)" to be displayed before the message explaining why it couldn't be taken.
One way round this is to capture the output from the take action, then test whether it succeeded so we can decide what form of the implicit take message to use, and only then display the captured message if we need to explain why the take failed.
"Intelligent Putting"
Include Text Capture by Eric Eve
Part 1 - Implicit Taking Mechanism
Before putting something on something when the noun is not carried:
if the noun is on the second noun,
say "[The noun] is already on [the second noun]." instead;
take the noun implicitly;
if the noun is not carried, stop the action.
Before inserting something into something when the noun is not carried:
if the noun is in the second noun,
say "[The noun] is already in [the second noun]." instead;
take the noun implicitly;
if the noun is not carried, stop the action.
To take (obj - a thing) implicitly:
start capturing text;
silently try taking the obj;
stop capturing text;
say "(first [if the obj is carried]taking[otherwise]trying to take[end if] [the obj])[command clarification break]";
if the obj is not carried, say captured text.
Part 2 - Scenario
The Lumber Room is a Room. "The Junk of decades has accumulated here."
A large wooden table is here.
A small red box is on the table. It is an openable open container.
An old black comb is here.
A spare sock is here.
A bust of King George V is here.
Instead of taking the bust: say "The bust is too heavy for you to lift."
Test me with "put comb in box/put sock on table/put table in box/put bust on table."