Conversations Coding Syntax

I am a hobbyist java/c# programmer - probably because of that - I prefer to use more C style formatting to my TADS code like:

VentEngine01: Room
{
    roomName = 'Ventilation System'
    initialDesc = 0
    
    desc()
    {
        if (initialDesc == 0)
        {
            "
You are in a hot black void. Hot metal presses against you on all sides, as far as you can tell it is open above
your head and below your feet. There is a constant deep grumbling sound all around.\b
You cannot remember anything. All is lost. All is void.
            ";
        }
        if (initialDesc > 0)
        { 
            "
You are still in a hot black void.
            ";
        }
        
        initialDesc = 1;
    };
};

etc…

Can I format conversations this way? The only examples I’ve seen use the:

+TellTopic
'...'
;

format.

I’ve tried placing the topics within the Actor’s brackets, or on their own but I’m not sure how to tie them to the Actor (I tried location = ) for kicks. Is this style of coding even possible with conversations - or am I stuck w/ the +…; format?

Thanks!

Have you tried this?

TellTopic { location = fredTheActor }

I’ve never tried it, but the ‘+’ syntax is referred to in “Learning T3” as equivalent to location =. So it might work.

Edit: The one thing about this to be aware of is that it’s quite common in T3 to nest anonymous objects using +, ++, and +++. If you use location =, you’ll have to give all of your Topic objects code names if they have other objects nested within them:

spongeTellTopic: TellTopic { location = fredTheActor }

There are three independent things here. The plus sign vs. location property, using on not using templates and using curly braces vs. only semicolon. The following should be interchangeable:

captain: Actor;

// prefered way
+ AskTellTopic @commander
    "<.p><q>Bla, bla...</q> "

    isActive = gRevealed('bla')
;

// replacing semicolon with braces - after template!
+ AskTellTopic @commander
    "<.p><q>Bla, bla...</q> "
{
    isActive = gRevealed('bla')
}

// moving response from template to property
+ AskTellTopic @commander
{
    topicResponse = "<.p><q>Bla, bla...</q> "
    isActive = gRevealed('bla')
}

// moving match object into property
+ AskTellTopic 
{
    topicResponse = "<.p><q>Bla, bla...</q> "
    isActive = gRevealed('bla')
    matchObj = commander
}

// and even the plus sign can be transfromed to property definition
AskTellTopic 
{
    topicResponse = "<.p><q>Bla, bla...</q> "
    isActive = gRevealed('bla')
    matchObj = commander
    location = captain
}

But please note that this is not a way to make your code better, but rather worse :wink:

It’s great that TADS gives you the option of using a different coding style if you like. And there’s so much in the T3 language and library that starting to learn it by building on what you already know may be a smart move. I have to say, though …

I came to T3 after a brief stint as a hobbyist C++ programmer (and even “hobbyist” is probably giving myself too much credit). What confused me at first was the declarative nature of the dobjFor() macro. It didn’t look like that code was doing anything.

What I only gradually grasped was that most C programs (and, I’m sure, programs in other standard languages) are procedural. That is, the coder writes procedures. IF languages, on the other hand, tend to be massively declarative. That is, the author creates stuff (rooms, things, doors, whatever) simply by declaring properties. The procedural activity is mostly carried out by the library.

As I see it, this is why the T3 system of templates and macros makes perfect sense. It simplifies the process of making declarations. They’re easier to type; and once you understand a few templates, they’re also easier to read.