using (heads $) doesn't work when object is a topic

using (heads *) works to help the parser differentiate two objects with overlapping names. an example would be the red bottle and red bottle cap in the dialog manual.

this works when it comes to “take”, “examine”, or any action where the objects are in scope. but if the bottle and cap are given (topic $) then it falls apart. asking an NPC about either object triggers the ambiguous parser response.

i think this may be a library bug or omission? i can’t imagine this would be the desired behavior. i’m guessing that the parser expects the (heads $) objects to always be in scope?

1 Like

You’re right!

(understand $Words as topic $Obj)
	(filter $Words into $Filtered)
	(determine object $Obj)
		*(topic $Obj)
	(from words)
		*(dict $Obj)
	(matching all of $Filtered)

This is the block in question, and it only looks at (dict $), not (heads $). That should probably be changed to add (words $Filtered sufficiently specify $Obj) to the criteria.

1 Like

i can’t seem to find the right place to add (words $Filtered sufficiently specify $Obj).

i’ve tried after the *(topic… and *(dict conditions but it doesn’t change anything.

This is how I’d do it:

(understand $Words as topic $Obj)
	(filter $Words into $Filtered)
	(determine object $Obj)
		*(topic $Obj)
		(words $Filtered sufficiently specify $Obj)
	(from words)
		*(dict $Obj)
	(matching all of $Filtered)

Results:

#player
(current player *)
(* is #in #room)

#room
(room *)

#apple
(name *) apple itself
(heads *) apple
(topic *)

#juice
(name *) apple juice
(heads *) juice
(topic *)

#book
(name *) book
(* is #in #room)
(consultable *)
(perform [consult * about $Topic])
	You look up “(no space) (describe topic $Topic) (no space)”.

> look up apple in book
You look up “the apple”.

If you comment out the (heads *) lines, or don’t make the change to stdlib.dg:

> look up apple in book
Did you want to consult the book about the apple itself or the apple juice?

This will be fixed in the next release.