Understanding "[text]" as a thing

The following compiles, somewhat to my surprise:

Chamber is a room. The set is scenery in Chamber. "Description of the set." Understand "[text]" as the set.

but I don’t know if I can recover the text that the player typed to refer to the set. That is, when the player types “x foof” it examines the set, as it should, but is there any way I can figure out that they typed “Foof”? The topic understood isn’t set.

(Why would I want to do this insane thing? I’m interested in whether I can set up some dummy objects with varying procedurally generated descriptions, and then have the player be able to refer to the objects using whatever’s in the descriptions. So if the player says “x clock,” I want to be able to trap the word “clock” and check whether some object whose description currently includes “clock” is in the room.)

Possibly helpful is bug report #66

Very interesting!

Thanks Ron, that is very helpful! The fix you included is particularly helpful; the I6 voodoo seems to work. Here’s something I have that has at least a little functionality:

[spoiler][code]
Chamber is a room. “A bright tapestry hangs on the wall and a rich carpet lies on the floor.” The set is scenery in Chamber. The description of the set is “This is a blank description.” The tapestry is privately-named scenery in Chamber. “Bright.” The carpet is privately-named scenery in Chamber. “Rich.”
Understand “[text]” as the set.
Before doing something when the set is the noun: [this should probably go in its own rulebook before “before,” and I would also have to do something for when the set is the second noun]
fix the topic understood;
if the topic understood matches “bright” or the topic understood matches “tapestry”:
change the noun to the tapestry;
otherwise if the topic understood matches “rich” or the topic understood matches “carpet”:
change the noun to the carpet;
otherwise:
say “That doesn’t seem to be here.”;
stop the action.

To fix the/-- topic understood: now the parsed number is (consult_from multiplied by 100) + consult_words.

Parsed number is a number that varies. Parsed number variable translates into I6 as “parsed_number”.

consult_from is a number that varies. consult_from variable translates into I6 as “consult_from”.

consult_words is a number that varies. consult_words variable translates into I6 as “consult_words”.

Test me with “x carpet/x rich/x bright/x yzzy”.[/code][/spoiler]

Now, I’m still not positive why “the topic understood” isn’t getting set here; it’s not the situation covered in bug 66 and WI 16.20, since the command isn’t a mistake and is understood. If I tried to attach a “when” condition to the understand line, it wouldn’t work as specified in 16.20, which is why I channel everything to a dummy object and then redirect it. But I’m not sure what it does take to set “the topic understood.”

Paul, thanks! Don’t expect to see anything working anytime soon; it’s just an idea I had for a tech demo, and today I thought of this as a possible hack for making one bit of it work.

I’m not quite sure why it should be set. If the command is X FOOF where the word “foof” matches some dummy object, then the dummy object becomes the noun, not the topic. The examine action applies to one noun, not topic. The fact that any word can be used to refer to the dummy object isn’t related to topics.

So it gets set whenever there’s an understand line that pertains to an action applying to one topic? I’m used to [text] tokens setting the topic understood, but that presumably works because they generally appear in understand lines for actions applying to one topic.

It looks like Ron’s I6 magic might be the way to recover the way the player referred to an object – but unfortunately it doesn’t straightforwardly work on actions with two nouns:

Chamber is a room. "A bright tapestry hangs on the wall and a rich carpet lies on the floor." The set is scenery in Chamber. The description of the set is "This is a blank description." The tapestry is privately-named scenery in Chamber. "Bright." The carpet is privately-named scenery in Chamber. "Rich."  The player carries an apple. There is a whatsit in Chamber.
Understand "[text]" as the set.
Before doing something when the set is the noun: [this should probably go in its own rulebook before "before," and I would also have to do something for when the set is the second noun]
	fix the topic understood;
	say "Topic: [topic understood].";	
	if the topic understood matches "bright" or the topic understood matches "tapestry":
		change the noun to the tapestry;
	otherwise if the topic understood matches "rich" or the topic understood matches "carpet":
		change the noun to the carpet;
	otherwise:
		say "That doesn't seem to be here.";
		stop the action.

Before doing something when the set is the second noun: [this should probably go in its own rulebook before "before," and I would also have to do something for when the set is the second noun]
	fix the topic understood;
	say "Topic: [topic understood].";	
	if the topic understood matches "bright" or the topic understood matches "tapestry":
		change the second noun to the tapestry;
	otherwise if the topic understood matches "rich" or the topic understood matches "carpet":
		change the second noun to the carpet;
	otherwise:
		say "That doesn't seem to be here.";
		stop the action.


To fix the/-- topic understood: now the parsed number is (consult_from multiplied by 100) + consult_words.

Parsed number is a number that varies. Parsed number variable translates into I6 as "parsed_number".

consult_from is a number that varies. consult_from variable translates into I6 as "consult_from".

consult_words is a number that varies. consult_words variable translates into I6 as "consult_words". 

Test me with "x carpet/x rich/x bright/x yzzy".

If I’m going to effectively hack the parser like this, I suppose I really need to learn how the parser and I6 work (or learn how the parser works through Ron’s I7 parser). [That’s ‘effectively’ meaning ‘in effect,’ not meaning ‘it’ll actually work’.]

I’ve been working from the opposite direction with my “objects matching snippets” extension. I don’t know if it would be useful to you, but here it is if you’re curious:

eyeballsun.org/i/Objects%20M … ippets.i7x

I’ll have to look at it, though I’m not sure it’s quite what I want. The thing is that I don’t want to use a “[text]” token [UPDATE: This is wrong; obviously I want a text token, but I don’t want an action applying to a topic, because…], because I want the player to be able to perform things on the dummy objects, and the thought of having to write Understand “x [text]” as dummy-examining and then writing rules to redirect dummy-examining to the dummy objects makes me want to stab my eyeball. (Plus I think you can’t say Understand “put [text] on [other text]” as putting it on.") So I haven’t got a snippet to match the objects against.

Also, when I try to include your extension in a project I get an abject failure. Have you experience that?

Aieeee! This is weird!

It appears that Objects Matching Snippets fails to compile by itself, even though it works fine when included by Speech Motivations. Let me see if I can figure out why…

I can’t even figure out where the error is in auto.inf. This is the least helpful compiler output I’ve ever seen!

[code]Include Objects Matching Snippets by Mike Ciul.

Test is a room.[/code]

I’m searching auto.inf for “scene understood” and “Rule Subtrees” … nothing. Hmm… I’m finding debug code from another project in auto.inf. I think maybe it didn’t get as far as generating I6 code?

Aha! Got it. I put the “ends here.” line before the end of the code. Fixed now - please download again.

eyeballsun.org/i/Objects%20Match … ippets.i7x

Apparently you only get abject failure if Objects Matching Snippets is the last extension included. That’s why I hadn’t seen the error before.

Do you still have the offending code? I’d like to reduce it and upgrade #379 to critical.

I’ve got it – should I PM you? What format?

Actually, I guess I wasn’t thinking when I posted, because I can just use the current version and move the ends-here line myself. But thanks for offering to send it.

FWIW, the section after “ends here” is “Testing Commands - Not for Release.”

Glad to see my bugs reaching a wider audience! :laughing: