How could I have known this? (TADS3)

In my continuing quest to understand TADS3 (and, parenthetically, actually write a game ) I often get stumped. Usually, one of the reference manuals (LT3, Getting Started, or the Tourguide) helps me out. But often they can’t and I am left stumbling around. Then, when I post a question here on the forum, some kind soul usually helps me out.

But I’d like to be smarter about this, and I’m wondering how to get smarter.

Just as an example, a few days ago I posed the question in a different thread, asking how to get a specific player input. ReINC responded with this great answer:

if (gAction.getOrigText().find('rembrandt')) {
    "The Rembrandt looks beautiful. ";
}

But it turns out there is only one reference to getOrigText() in the manuals (other than the Library Reference Manual itself), and nothing that I can think of that would have led me to know about .find() or to use it in this context.

So my question is, How could I have know this? (And by extension, other things like this - such as the question someone else raised that was answered by using setIt(obj) ?)

Is the answer that I have to read through the (massive) symbol list and hope that I can remember what everything does? Or is there a simpler way?

The way I came up with that answer was the idea of searching for the word in question in the string returned by getOrigText(). How do I search for something inside a string? The string class probably has a method for this. Where do I find the methods of the string class? In the header file that declares that class. The file is “include/systype.h”. I looked in that file, and found the find() method in there.

In general, I always consult the source files that come with TADS when I want to find something. They are well commented (actually, about 80% of the text in the source files consists of comments and only 20% is actual code.)

“grep -r” (or “-ri” for case-insensitive search) is my preferred way to search those files (I’m on Linux.)

In the getOrigText() case, the way I would have found it, would be to look up the definition of the Action class. To find where this class is defined, I would search for “class Action:” with:

grep -r "class Action:"

This shows this result:

lib/adv3/action.t:class Action: BasicProd

So I know the Action class is defined in lib/adv3/action.t, and I also know that Action is derived from the “BasicProd” class. First, I would look in the Action definition in action.t to see if there’s something I can use. Then, I would look in the BasicProd definition (grep -r “class BasicProd:” to find the file BasicProd is defined in). It’s in lib/adv3/parser.t. And indeed, getOrigText() is defined there:

[code]*

  • The basic production node base class. We’ll use this as the base
  • class for all of our grammar rule match objects…
    /
    class BasicProd: object
    /
    get the original text of the command for this match /
    getOrigText()
    {
    /
    if we have no token list, return an empty string /
    if (tokenList == nil)
    return ‘’;

    /
    build the string based on my original token list */
    return cmdTokenizer.buildOrigText(getOrigTokenList());
    }[/code]

On Windows, you can just use the file manager to search for text in files, I think. It won’t show as much detail as “grep” on Linux and Mac, but it should help find the files you’re looking for.

I’ve answered the setIt/setAntecedents question, because it was quite easy question for me as I’ve used it in my own game. But in the first place, I know about these methods because prior to writing my game I’ve made a Czech translation of TADS and carefully replaced grammatical gender system by my own :slight_smile:

I can second the hint about fulltext searching the library, when you carefully choose keyword, there is chance you will pickup some explanation of the problem in comments.

Once you are quite familiar with Learning TADS 3 and all the coding excursus, you can take a look on the System manual (and Technical manual). Not to learn everything, but more to get some overview what is possible or at least what chapters are there. Later you should remember that you already saw something interesting there and you will know where to look.

For example find() is an intrinsic function of the String class and you could look here to have an idea what else is possible (comparing, finding, replacing, calculating length, matching, spliting, substringing, lower/uppercasing). Many of these features are easily anticipated because every programming language have something like this.

Oh, and by all means read the source code of Mike’s Return to Ditch Day, it a major sample game for TADS 3 and you will be amazed how many interesting tricks you will learn! setHim/getOrigText/rexSearch included :slight_smile:

So there are lots of different ways, but in the end it is all about patiently gaining experience over time. I’m a professional programmer by day, I teach kids programming few hours a week, so it’s probably easier for me to gain the experience, but still I can get horibly stuck for months and yet there is someone who can answer with ease. So don’t be afraid to ask questions, good questions will lead to good answers which will be valuable resource for others. And give it the time, your second game will be much better and much easier to write then the first one.

Thanks for these thoughtful and useful answers!