Objects not in Scope (adv3Lite)

At a certain point, the player is probably going to want the PC to ask a certain NPC to give her a certain thing. Unfortunately, the thing in question is not in the room at the time. (It will be revealed later.)

I’ve got it working in response to ‘ask (NPC) for (that thing)’. That triggers an AskForTopic, so I can define a Topic object and it will be matched. However, the command ‘(NPC), give me (that thing)’ doesn’t work with the Topic object. This should be handled by a CommandTopic, but it isn’t. The player’s input falls through to the DefaultAskForTopic. The CommandTopic is defined for the GiveTo action, but no matter what I put in the matchDobj and matchIobj properties of the CommandTopic object, it isn’t matched. I even tried putting an Unthing in the room. It didn’t match that. Then I tried a Doer. No soap.

In Inform 6, one would do this with add_to_scope, IIRC. But in order to do the equivalent in T3, I would need to know where the gDobj is being identified, so as to stick the Topic object into the code. It’s not clear to me how to do that. Suggestions would be welcome!

Just shooting in the dark since I haven’t had time to sample test your problem, but could you go all the way back to modify GiveToAction, and tweak the objInScope code to include your situation?
Have you read ‘Redefining Scope’ in the adv3 Tech Manual?

Thanks for the suggestions, but the adv3 Tech Manual isn’t included in the adv3Lite docs, and I’m pretty sure there’s no reason why it would be. The TADS 3 System Manual is included, but that’s a different thing.

The way adv3Lite works, the GiveTo action is defined in the Thing class using dobjFor(GiveTo). But that’s not going to help, because the direct object of the command isn’t in scope, so its dobjFor(GiveTo) will never be called.

Here’s a very simple test game. It’s complete except for the default versionInfo and gameMain.

widget: Thing 'widget'
    "It's a jolly widget. "
    familiar = true
;

startroom: Room 'The Starting Location'
    "Add your description here. "
;

+ me: Thing 'you'   
    isFixed = true       
    person = 2
    contType = Carrier    
;

+ bob: Actor 'Bob'
    "Here's Bob! "
;
++ bobHere: ActorState
    isInitState = true
;
+++ CommandTopic @GiveTo
    "Here we\'re COMMANDING Bob to give us the widget. "
    matchDobj = widget
;
+++ AskForTopic @widget
    "Here we\'re politely asking Bob for the widget. "
;
+++ DefaultAskForTopic
    "Here we're asking Bob for something that's not available. "
;
+++ DefaultCommandTopic
    "Here we're handling the case where Bob has been commanded
    to give something that's not in scope. "
;

Test 'widget' ['ask bob for spinach', 'ask bob for widget', 'bob, give me widget']
;

Note that the widget is not in scope, but is defined as familiar. Thus it can be referred to in the AskForTopic. Here’s the output:

>test widget
Testing sequence: “widget“.

>ask bob for spinach
Here we’re asking Bob for something that’s not available. 

>ask bob for widget
Here we’re politely asking Bob for the widget. 

>bob, give me widget
You see no widget here.

The widget is never considered by adv3Lite as a possible matchDobj for the GiveTo command.

I may be no help here, because again, not having researched and experimented myself… but when you command Bob to “give”, this should invoke the basic GiveToAction (I’m speaking from adv3 perspective, it’s all I know.) GiveToAction uses the normal objInScope method, i.e., what’s in the actor’s scopeList. It doesn’t check for knowledge or familiarity… it seems to me like you’d have to tweak that method to allow Widget to be in scope at that point…
Sorry if I’m just rambling stuff you know and have tried already…

I know that for adv3 there is a TCommand extension, but perhaps that is already incorporated into Lite?

There is no GiveToAction in adv3Lite. I searched the library code. Searching for GiveTo gives me several lines of code in the library, but none of them is obviously going through the process of scoping.

My bet is, scoping is handled in adv3Lite by the Parser object. I had a look at that last night, and I couldn’t make heads or tails of it.

Because I prefer to leave no stone unturned, I tried stepping through with the debugger. By the time we get to grammarInfoForBuild(), which does nothing but return GrammarInfo(), it has already been decided by the parser that in the input phrase “bob, give me the widget”, token 6 (‘widget’) is nil. I don’t know when that happened. I was watching step by step using F11, but I didn’t see it.

Bummer, I guess I’m in the dark if Lite differs that much in processing from adv3… I don’t know how often RealNC looks over these posts, but he usually can answer the difficult technical questions…

I don’t know much about adv3Lite, unfortunately.