Trying to understand conversing with an NPC

#1

I’ve read various docs and I can’t figure this out. I’m trying to do something along these lines:

talk to npc

npc says “something about a dagger.”

ask npc about dagger

npc says “something about slaying monsters.”

I’ve tried the following as far as the second part goes:

[code]npc: Actor ‘npc’ ‘npc’ @startRoom "Npc "
;
+npcDefault: ConversationReadyState
isInitState = true
;
++ AskTopic @dagger
"npc says somthing about slaying monsters. "

isActive = true

;
[/code]

I get a ‘nil object reference’ on the following line in file actor.t (line 4864 of the ‘handleConversation(otherActor, topic, convType)’ method for class ‘ConversationReadyState’):

inConvState.handleConversation(otherActor, topic, convType);

The Watch Expressions window indicates it’s the inConvState object that’s nil. I’m clearly missing a step (or two), but I don’t know what it is.

I have no idea how to handle the simple talk to npc action

Thanks.

0 Likes

#2

Conversations in TADS are rather big chapter in Learning T3 manual and it will take you some time to grasp. Talk to NPC is part of hello/goodbye protocol which are discussed in chapter 14.6. Follow the examples in the book. You’ve got error because ConversationReadyState is meant to be used together with InConversationState and please follow the exact containment hierarchy given by plus signs:

[code]npc: Actor ‘npc’ ‘npc’ @startRoom "Npc "
;

// one plus sign to locate into NPC

  • InConversationState
    attentionSpan = 5
    specialDesc = "Description for room. "
    stateDesc = "Description for examine. "
    ;

// two plus sign to locate ConversationReadyState always inside InConversationState
++npcDefault: ConversationReadyState
specialDesc = "Description for room. "
stateDesc = "Description for examine. "
isInitState = true
;

// one or two plus signs for topics depending whatever it is global topic or only for this particular state
++ AskTopic @dagger
"npc says somthing about slaying monsters. "

isActive = true // Not necessary, everything is active by default

;
[/code]

There are more advanced examples with Hello and ByeTopic n the book to give you smooth conversation, but always watch out for containment hierarchy, HelloTopic should be located into ReadyState with three plus signs.

0 Likes

#3

Thank you. I had read that (the entire chapter, in fact) but for some reason was stuck on the concept. This helped.

0 Likes