Game Help

Is there another error? Now with single quotes nothing is outputted for the name. Usually this is because something else is set, or something isn’t? I found this sometimes when needing to use something like specDesc instead of desc.

You probably just introduced the error when you changed the quote types. Did you add return before your now single quoted string? return makes the function stop and return the value after it. This isn’t necessary to print single quoted strings. In this case the game is expecting a string. The return is just passing the sting out of the function to the game. It receives the string and uses it to build the text it will eventually display.

Perfect, thanks david. There’s one other thing bugging me. I couldn’t figure out how to structure the names properly. What’s the common way of doing this. I’ve got a method that I kind of like, but I’m not sure about it.

When the characters are known their names output like Gert (the barkeep), Iro (the lighthouse keeper), and Morgan (the librarian)

I tried using --, but it looked weird with the commas separating them.

Gert-- the barkeep, Iro-- the lighthouse keeper, and Morgan-- the librarian

That usage of dashes is very non-standard. It won’t look good. I suggest no parentheses either. Just refer to her as Gert the barkeep, and so forth. This is standard English punctuation (that is, no punctuation for a closely related appositive phrase, such as “my aunt Cicely” – no good writer would put punctuation after “aunt”).

Okay, fixed that. Thanks :slight_smile:

I’m running into a logical error that I don’t understand. It’s as if ira.unknown doesn’t stay known on first talk.

[code]ira : Person ‘ira the lighthouse keeper/man/guy/drunk/alcoholic/sailor’
name {

    if(ira.unknown)
        
      return 'an old drunken sailor';
        
    else return 'Ira the lighthouse keeper';

}

desc = “<>He<>Ira<>'s an old-- <>thin faced<>leathery faced<>-- man with a lot of years on him. He looks as though he’s
spent a fiar bit of his life fairing the sea. The air around him smells of salt, fish, and cheap ale.”
location = leakyTub
isProperName = true
isHer = true
cannotKissActorMsg = '<>He<>Ira<>‘s not of a generation that welcomes outward shows of affection.’
cannotEatMsg = ‘Whatever else <>He<>Ira<> is, he is definitely not that tasty.’
uselessToAttackMsg = ‘Beating up <>the drunken man<>Ira<> will likely get you kicked out of the tavern.’
globalParamName = ‘Ira’
properName = ‘Ira’
unknown = true
questAccepted = nill
questCompleted = nill

dobjFor(TalkTo)
{
    
    action()
    {
        
        if(ira.unknown)
        {
            
            "<q>Ah? Wah? *hic*</q> He seems to be heavily intoxicated. <q>Ahh, name's...</q> He can barely keep his head up
            <q>Ira. *hic* I'm the lighthouse keeper.<q> When he finally gets his name out his head rolls down, then back up again. </q>Oh, my... Can't
             send me' boys out fish'n. Darn net's busted. Looks worse than me socks!</q> He complains. He sees to have lost his train of thought. 
             <q>Maybe ye' could help me, young man?</q> 'tell Ira yes' or 'tell Ira no'.";
            
             ira.uknown = nill;   
            
        }else 
        {   
         
            "Iras ask topics: Leaky Tub, <<if me.knowsStormPort>>Storm Port<<else>>town<<end>>, <<if !gert.unkown>>Gert<<else>>barkeep<<end>>, Salvia, <<if !gert.unkown>>Morgan,<<else>>sober guy,<<end>> lighthouse, net /b";
            
            if(!ira.questAccepted && !ira.questCompleted)
            {
            
                "Iras tell topics: yes, no";
            
            }
            
            if(ira.questAccepted)
            {
                
                if(!ira.questCompleted)
                {
                
                     "Iras tell topics: net";
                
                }else{
                    
                    "";
                    
                }
            }
        
        }
        
        // End action TalkTo (Ira)
    }
    
   // End direct dobjFor TalkTo (Ira)
}

;[/code]

Well, for starters, you’ve got this:

ira.uknown = nill;

There are two typos in that line.

Yes, you’re right. Sorry, I had a long night of typing. Those are all fixed. Right now I’m hung up on conversations. The manual is a bit sparse on the details…

Here’s my intel:

match object is an object that triggers the conversation? What if you wanted the topic to be about a non-object, like a word. Ask Gert about town, for example.

topicResponse is what will be read back. Just wondering, what if you wanted the topic to only relate to certain characters?

+ AskTopic matchObject = tTrollope topicResponse = "<q>Tell me, aunt, do you really think Anthony Trollope is such a great novelist?</q> you ask.\b <q>I find his writing infinitely preferable to your idle chatter,</q> she replies frostily. " ;

Thanks,
Jeremy.

You can easily create Topic objects that are not Things. All they are is a set of vocabulary words. If there’s no AskTopic embedded in a given NPC that includes that matchObject, then the NPC won’t respond to it.

How do you define them as vocabulary words inside the character. I don’t see it in the books…

We’ll just gut on of my characters as an example.

morgan : Person 'morgan the sober librarian/man/guy/librarian'
    name = 'Morgan the book lover';
    desc = "He loves books."
    location = leakyTub
    isProperName = true
    isHer = true
    globalParamName = 'Ira'
    properName = 'Ira'
    known = nill
    
    dobjFor(TalkTo)
        {
    
            action()
            {
        
                if(!known)
                {
                  
                     "Hi, I'm Morgan.";

                }
         }
    }
;

The short answer is, that’s not the T3 way to do it. You don’t put anything in a TalkTo block in the character. You create the character and then add topic responses as shown starting on p. 219 of “Learning TADS 3.” It’s really quite easy, and this system eliminates the dangers of embedded if-tests and that type of thing. If you want to include a topic that’s not an in-game object, you first define it as a Topic object:

tWeather: Topic 'weather';

Then you embed an AskTopic using + notation under your character:

[code]morgan : Person ‘morgan the sober librarian/man/guy/librarian’
name = ‘Morgan the book lover’
// etc.
;

  • AskTopic @tWeather
    "Here, Morgan tells you what he thinks about the weather. "
    ;[/code]
    This approach has some advantages. It’s easier to maintain, it gives you ready access to several varieties of conversation (Ask, Tell, AskTell, etc.), it allows you to set up AltTopics, which are quite handy, you can turn a topic into an EventList, and so forth.

Note that in the sample code you provided for Morgan, you have an extraneous semicolon after the name property. This semicolon ENDS the definition of the morgan object, which means that your code as given won’t compile at all. Really, it’s better to compile often and only post stuff that you know has compiled but isn’t producing the desired results. (This was also true yesterday of your uknown = nill line – that would never have compiled.)

Hey, thanks. Sorry for the questions, but it’s the only thing that helps. Now I understand you need to stack these in order. Every topic under the character that will speak them. I couldn’t derive that from the book. I’m not sure if it’s explained or not in there, maybe I’m just not reading well enough…

You solved my issue though. It’s likely going to be the same for all topics?

Also the semicolon is not an issue. Everything compiles and runs as I wanted it to.

You’re a good teacher :slight_smile:

Now that I look closer, that’s because you block-copied parts of two or three different NPC objects while creating your forum question. You have morgan, Ira, and isHer = true all in one block there.

You also have nill on one line. That’s not a T3 value. The code will compile with “nill”, but the compiler will give you a warning, and the code won’t work as you intend it to.

Yes, with one caveat, namely, you wouldn’t want to define a Topic object to handle vocabulary that is already handled by an in-game object. For instance, if you have an object with a vocabWords that includes ‘weather’, you should not create a separate Topic object tWeather using the word ‘weather’ in its vocabulary, as that will confuse the parser.

Hello,

I was just wondering if you can use if statements in an AskTopic. I’ve got one, but the compiler is throwing an error.

The compiler expected a function or object definition, but found “if”. Check
the syntax, and check for unbalanced braces ‘{ }’ and other syntax errors
preceding this line.

[code]+AskTopic @tStormPort;

if(!gert.mentionedStormPort)
{

    "\"Storm Port's a nice old place. Tad bit stormy, but the winds and rain never stop. People are usually rather 
    friendly, and we don't bother nobody\" She looks about
 the place, taking in the people around her. \"Most of the boys make their living off fishin', and ship'n goods, but
 we also got a farmstead growing our crops over on the eastern side of town.\" She chuckles. \"Strange place that is, 
over at the farm.\" She smiles, \"And you can also find the light and the library over that way too.\"";
    mentionedStormPort = true;
    me.knowsStormPort = true;

}else{

    "\"We live in the most beautiful town in all Amalia.\" She laughs. \"Some people find it to be a bit too stormy 
    for their taste buds, but we figure they should grow a spleen, dear.\" She looks about. \"Our boys go out in rough
    old seas.\" She wanders in her train of thought. \"In case you forgot you can find the farmstead, lighthouse,
    and library on the eastern side of town. Oh, and I may have forgot, but you can find the mayor up on wooded pass.\" She looks
    as if she realises she's got work to do. \"Well, I should get back to work, dear.\"";
    
    // try to remember to put character in work state.

}

;[/code]

Thanks,
Jeremy.

You can’t use if statement that way. The first problem is extensive semicolon on first line which terminates the topic object, so your if floats nowhere. Second problem is that you can only use if statements (an any other statements) only in methods (or functions). So instead of double quoted response you can declare topicResponse method and there you can use your if statments.

But I would strongly suggest that you rather shouldn’t branch the topic using if statements, rather you should use AltTopis for this as discussed in Learning T3 manual. Please see extensive rationale there.

Cool, can you help me with it?

+AskTopic @tStormPort
 
      "\"Storm Port's a nice old place. Tad bit stormy, but the winds and rain never stop. People are usually rather 
        friendly, and we don't bother nobody\" She looks about
     the place, taking in the people around her. \"Most of the boys make their living off fishin', and ship'n goods, but
     we also got a farmstead growing our crops over on the eastern side of town.\" She chuckles. \"Strange place that is, 
    over at the farm.\" She smiles, \"And you can also find the light and the library over that way too.\"";
        mentionedStormPort = true;
        me.knowsStormPort = true;
    
;

++altTopic 
     
    // Gert will say this if player does not know Storm Port and gert has not mentioned storm port
     "\"We live in the most beautiful town in all Amalia.\" She laughs. \"Some people find it to be a bit too stormy 
        for their taste buds, but we figure they should grow a spleen, dear.\" She looks about. \"Our boys go out in rough
        old seas.\" She wanders in her train of thought. \"In case you forgot you can find the farmstead, lighthouse,
        and library on the eastern side of town. Oh, and I may have forgot, but you can find the mayor up on wooded pass.\" She looks
        as if she realises she's got work to do. \"Well, I should get back to work, dear.\"";
    
    isActive = !me.knowStormport && !gert.mentionedStormPort
;
+AskTopic @tStormPort
     topicResponse () {
      "\"Storm Port's a nice old place. Tad bit stormy, but the winds and rain never stop. People are usually rather 
        friendly, and we don't bother nobody\" She looks about
     the place, taking in the people around her. \"Most of the boys make their living off fishin', and ship'n goods, but
     we also got a farmstead growing our crops over on the eastern side of town.\" She chuckles. \"Strange place that is, 
    over at the farm.\" She smiles, \"And you can also find the light and the library over that way too.\"";
        mentionedStormPort = true;
        me.knowsStormPort = true;
    }
;

++altTopic 

    // Gert will say this if player does not know Storm Port and gert has not mentioned storm port
     "\"We live in the most beautiful town in all Amalia.\" She laughs. \"Some people find it to be a bit too stormy 
        for their taste buds, but we figure they should grow a spleen, dear.\" She looks about. \"Our boys go out in rough
        old seas.\" She wanders in her train of thought. \"In case you forgot you can find the farmstead, lighthouse,
        and library on the eastern side of town. Oh, and I may have forgot, but you can find the mayor up on wooded pass.\" She looks
        as if she realises she's got work to do. \"Well, I should get back to work, dear.\""; // <-- DELETE THIS SEMICOLON
    
    isActive = !me.knowStormport && !gert.mentionedStormPort
;

…oh, also there are a couple of typos. You have knowsStormport the first time and knowStormport the second time – and I’m pretty sure that in the first object you need gert.mentionedStormport, not just mentionedStormport.

You’re right, thanks for that. I fixed those, but there’s still errors.

On the following line I’m getting error:

A property name was expected in the object definition, but the compiler found
“.” instead. Check for a missing semicolon at the end of the object
definition, and check for unbalanced braces prior to this line.

source\storm port - characters.t(78): error:
A property name was expected in the object definition, but the compiler found
“.” instead. Check for a missing semicolon at the end of the object
definition, and check for unbalanced braces prior to this line.

gert.mentionedStormPort = true;

And for the following this error:

source\storm port - characters.t(91): error:
Invalid expression; expected an integer value, a string value (in single or
double quotes), a symbolic name (such as a function, object, or property name),
a list constant enclosed in square brackets ‘[ ]’, or an expression in
parentheses ‘( )’, but found “&&”.

source\storm port - characters.t(91): error:
Invalid expression; expected an integer value, a string value (in single or
double quotes), a symbolic name (such as a function, object, or property name),
a list constant enclosed in square brackets ‘[ ]’, or an expression in
parentheses ‘( )’, but found “&&”.

isActive = !me.knowsStormPort && !gert.mentionedStormPort;

[code]+AskTopic @tStormPort

  "\"Storm Port's a nice old place. Tad bit stormy, but the winds and rain never stop. People are usually rather 
    friendly, and we don't bother nobody\" She looks about
 the place, taking in the people around her. \"Most of the boys make their living off fishin', and ship'n goods, but
 we also got a farmstead growing our crops over on the eastern side of town.\" She chuckles. \"Strange place that is, 
over at the farm.\" She smiles, \"And you can also find the light and the library over that way too.\"";

gert.mentionedStormPort = true;
me.knowsStormPort = true;

;

++altTopic

// Gert will say this if player does not know Storm Port and gert has not mentioned storm port
 "\"We live in the most beautiful town in all Amalia.\" She laughs. \"Some people find it to be a bit too stormy 
    for their taste buds, but we figure they should grow a spleen, dear.\" She looks about. \"Our boys go out in rough
    old seas.\" She wanders in her train of thought. \"In case you forgot you can find the farmstead, lighthouse,
    and library on the eastern side of town. Oh, and I may have forgot, but you can find the mayor up on wooded pass.\" She looks
    as if she realises she's got work to do. \"Well, I should get back to work, dear.\"";

isActive = !me.knowsStormPort && !gert.mentionedStormPort;
;[/code]

You’re not reading my edited code closely enough. Go back and read it again. You still need to put topicResponse() {…} around the topic response in the AskTopic, and you still need to get rid of the semicolon after the string in the altTopic. Oh, and also, AltTopic should be capitalized.

TADS is a well structured language. It’s not like Inform 7, where you can just throw a bunch of stuff in higgledy-piggledy and let the compiler sort it out. The AskTopic is an object, that’s the first point. Like other objects, its definition ends with a semicolon. You can’t put semicolons in the MIDDLE of an object definition unless they’re in code blocks. You haven’t defined a code block within the AskTopic. Your topicResponse (the quoted material) will be understood by the compiler as a topicResponse if and only if it matches the template. Because you want to put some additional code ( = true ) in the topicResponse, you can’t use that part of the template. Instead, you must manually tell the compiler that those three lines (the quote and the two = true statements) are code within a code block – which means you have to manually include topicResponse() { }, with the brackets around your code.

Because the topicResponse you’ve written for the AltTopic uses the template, you cannot end the quoted material with a semicolon. That semicolon ends the object definition of the AltTopic, leaving your isActive statement floating.

Does that explanation help at all?

Hey, sorry Jim. I wasn’t ignoring you. I missed that post to be honest. That freed up a lot of bugs. I found a couple more that came to light, and now my game is working again. I’m pumped. I’ve got some new vigor for the project now that I have some time for it.