NPC AskTopic not working

I am working with TADS3. I have created an NPC and want to be able to ask it about objects. I coded it like it showed in the tutorials, but it is still not working. The HelloTopic is working fine. I am new to IF, but I am enjoying it. Could someone guide me in the right direction to make this work?
NPC.txt (2.52 KB)

AskAboutTopic doesn’t exist.

The following are listed in the docs:

AskAboutForTopic
AskConnector
AskForTopic
AskTellAboutForTopic
AskTellGiveShowTopic
AskTellShowTopic
AskTellTopic
AskTopic

Use AskTopic. The other issue is, do you have Merrick defined in the game, and set in a room? You can’t reference him if he doesn’t exist in the game. Also the topic only works for items, or people, the player has seen before. So no good for first time looking for Merrick. You can set merricks seen variable to true as a quick hack. That’s best if you don’t need to rely on it later for anything.

Someone else may be able to post better advice.

tads.org/howto/t3conv.htm

I got it.

set this variable in your asktopic

isConversational = true

Then you don’t have to see the object first

Merrick is defined, although he is hidden. The topic is labeled AskTopic. I want him to respond to ask about Merrick. If you could look over my code, that I copied into a text file, and perhaps show me where I can fix this I would greatly appreciate it.

My entire code for character: (I apologize for not knowing how to post my code Properly.)

#charset “us-ascii”
#include <adv3.h>
#include <en_us.h>

/*

  • Mr. Jingles (Rat) Created by : Mitch Roberts Date: 10/8/2016 Created to be
  • a companion and clue giver to player
  • Maintenance log:
  •  10/9/2016       Added Shuffled event list for some random speech MR 
    
  •  11/10/2016      Added AccompanyingState for travel with player MR
    
  •  11/10/2016      Created .t file for mrJingjes MR
    
  •  11/11/2016      Added image to mrJingles MR
    

*/

//An NPC that can give you clues as you traverse the game
mrJingles: Actor
‘rat’
‘rat’
desc = “


<img src=“mrJingles.jpg” width=“150” height=“150” align=“top”>
Just an ordinary looking rat, but he seems like he wants to talk?”
bulk = 2
location = TownSquare
destination = AccompanyingState
isHim = true
dexterity = 10
globalParamName = ‘rat’
isConversational = true
//Make references to mrJingles use proper name instead of rat
makeProper(properName)   
{      
    name = properName;      
    isProperName = true;      
    initializeVocabWith(properName.toLower());      
    return name;   
}


//Have mrJingles change state to discovered  
  dobjFor(TalkTo)

{
verify() { }
check()
{
if (mrJingles.isHim)
{
moveIntoForTravel(LeatherPouch);

        setCurState(mrJinglesDiscovered);
            
    }
}

}

;

//Once discovered mrJingles will accompany player
+mrJinglesDiscovered : AccompanyingState
specialDesc = " Mr. Jingles is accompanying you. "
stateDesc = " Mr. Jingles is with you. "
accompanyTravel(leadActor, conn)
{ return leadActor == gPlayerChar; }

;

//Response to ask about Merrick

  • AskTopic @Merrick
    topicResponse()
    {

    “What can you tell me about Merrick you ask. <.p>You should find
    Merrick.” He says in an excited tone. He has something very
    useful! I hear that Merrick and Endora were once lovers.";

    }

;

//Random conversation for mrJingles
++ HelloTopic, EventList [

'The rat looks up at you. Hello, I am
 <<mrJingles.makeProper('Mr.Jingles')>> . ',

'It is nice to finally have someone to talk to.',

'Be careful in this town, it can be very dangerous.'

]

;

++ mrJinglesSouthGateAgenda: ConvAgendaItem
isReady = (mrJingles.canSee(SouthGate))
invokeItem()
{
‘Mr.Jingles says, “This Gate is quite beautiful. I wonder what the S is for?”’;

}

;

Are you using the WorkBench? You do know that it has a debugger. Every time you press the play button, if the game doesn’t run, it will give you a list of errors telling you reasons your game is not running. It’s “debug log” file at the top of your window. It’s in the same line of tabs as your main game file. Sometimes you have to make a change in your game file text, save, and retry to run to get the debugger tab to popup with errors.

One error:

TownSquare is not defined - this error “defined” means that it wasn’t created, or in programming terms “defined” or “instantiated”.

a = 1 is a definition of a variable. It’s also instantiating a variable.

You try to access it in code, but you didn’t even make the room yet.

[code]mrJingles: Actor
‘rat’
‘rat’
desc = "


<img src=“mrJingles.jpg” width=“150” height=“150” align=“top”> Just an ordinary looking rat, but he seems like he wants to talk?" bulk = 2 location = TownSquare destination = AccompanyingState isHim = true dexterity = 10 globalParamName = 'rat' isConversational = true [/code]

location = TownSquare

error 2 LeatherPouch is undefined
error 3 Merrick is undefined
error 4 versionInfo defined in external file, but not in source
error 5 mainGame defined in external file, but not in source.

Are you sure you passed us every line of code, character definitions, and item definitions?

Define those things, and pass me back the code. I already explained how to do it in the first post, but… I’ll write it in for you, and show you where I changed it, if you send complete game code.

Just a tip. You should code in small chunks, testing often. That way you can nip errors in the bud. It’s better than writing a whole book of code, and having to sift through the debug log, and using breakpoints.
debugtab.jpg

While you’re working on that I’ll teach you a couple of other handy debugging tricks that I’ve learned.

  1. Write code in chunks, testing often, to catch bugs early.
  2. Use the debug tab that I showed you, which reports all game stopping errors.
  3. Take out chunks of code and paste them into notepad. Run you’re game. This will help you find the error. When your game runs, the problem code is in notepad.
  4. Breakpoints.

Breakpoints sound confusing when you’re new, but they’re really easy, and handy as all got out.

Read the images and comments from the bottom of the post to the top.

Note - breakpoints are not a fix all. You can’t highlight functions and see return values.

Best practice is to use all these methods together, and you’ll become bug narrowing beast! lol
break4.jpg
break3.jpg
break2.jpg
break1.jpg

All of those objects are defined in the game. This is just a character that I have created for the game. It does compile and run. The only things that won’t work are the AskTopic and the SouthGate Agenda. I could send you the game source file if you like. It’s too big to upload here.

I set the break point and ran the debugger, When I type in ask about Merrick it never goes into the break point. For some reason it’s not going into the AskTopic function.

Sorry, I was wrong about isConversational. I don’t know why I thought this halped last night. Was very early. The only thing I could think of while looking at how conversations worked is to set Merrick to seen. That way the AskTopic thinks that Merrick is known. If it’s important that Merrick is not seen for some reason, you can tick it back in the same conversation. This will cause problems in the future though if you ever have games where you might run into Merrick before another character, because when you talk to the other person he willl be set to seen = false.

If you absolutely know that Merrick will not be seen before rat is talked to you could use this method.

Like I said, it seems like a hacky solution. It works, but could be problematic in other games. I’m eager to see what others suggest. There must be a way to ovverride the AskTopics neccisity of seeing the object first. I don’t see it in the docs though.

The way Tads is designed is that it’s asking about something, and to do that you have to know about it.

To hack your way out this dilemma is you could set your object to seen, but add a variable known = false. Then in all instances where you would normally check seen, just check known. You could add a function to the character that sets known, then you can switch it how you please.

+ AskTopic @Merrick
    
topicResponse()
{

"<q>What can you tell me about Merrick</q> you ask. <.p><q>You should find
Merrick.\"</q> He says in an excited tone.<q> He has something very
useful!</q><q> I hear that Merrick and Endora were once lovers.</q>";
    Merrick.seen = false;

}

;

Merrick : Actor 'Merrick' 'Merrick'
    seen = true;
    
;

Thanks I will try the known variable in the Merrick object. I really do appreciate you working with me to figure this out. I have a lot more askTopics that I want this character to respond to throughout the game.

I added the isKnown = true statement to the Merrick character and now the askTopic works fine. Wow Thanks for your help.

Just few notes: isConversational is for controlling Hello and Goodbye protocols. When it is true (default) and player starts conversation about such object, then greeting is performed. You can set it to nil to suppress hello and goodbye for such topic. Useful when reply for topic is not a dialogue but rather a message telling that the character does not like to talk about it.

You must mark as known any object the player character didn’t seen yet, i.e. never ever been in the same room.

No problem. I’m far from excelled at this, but have picked up on a couple of things. I can’t answer advanced topics, as I usually look for hacks to solutions I don’t understand, or know. Sometimes I get it with a little help, lol.

One other thing I noticed from glancing at your code. It looks as if you’re moving Mr. Jingles into a leather pouch, which presumably the player is carrying. If that is the case, you may not need the AccompanyingState, which is used for NPCs who follow the player around from room to room.

Eliminating the AccompanyState will remove what would probably be an annoyingly repetitive msg each time you go from room to room - “Mr. Jingles comes with you.”

(Of course, if you do this, make sure the player can’t drop the pouch!)

–Bob