String templates

Just wanted to share with fellow TADS programmers the power of string templates, if you’re not using them already.

When I reacquainted myself with the language a few months ago, I assumed EventLists and other programmatic tricks were necessary to perform such common tasks as random messages or describing a room in an interesting way on first entering, and more matter-of-factly thereafter.

Then I squinted and studied the section of the TADS Language Manual on string templates closer: String Literals

This seriously changed my life. Rather than hand-wiring a lot of special-case code, I could let the compiler do the heavy lifting.

One problem I had is how the documentation listed examples, which embeds the templates in paragraphs of text. I’m using a structured approach and it’s working well:

hallway: Room 'Hallway'
  You stand in an ornate hallway.
  <<one of>>
    You're surprised to see so much marble and gild in an ascetic's home.
    Marble and gild surrounds you.

– Jim


I make heavy use of these… indeed helpful.
As well as the “if” and “else” constructs within double angle brackets…

1 Like

I noted these string literals; put TADS3 nearer I7 in the field of adaptive prose. (I pointed about this in the long debate about strenghts and weakness of IF languages)

I think that is a time for a major upgrade/update of the three manuals, whose pre-dates, or give a very cursory reference to, the new string literals.

personal note: Because I’m toying/fooling around the concept of “knowledge and lore as treasure (hunt)” and the isekai plot device(s), I’m doing heavy experimenting work on adaptive prose…

Best regards from Italy,
dott. Piergiorgio.


I too am developing a game based heavily on uncovering knowledge, and using Topic-based criteria for ordering how some may be discovered (i.e., Topic B may not be learned without learning Topic A first).

It’s an interesting way to approach game design. There’s two maps: The map of locations to be traversed, and the map of knowledge to be gleaned.

– Jim


Actually the two maps, locations, and knowledge/lore are interconnected, and mutually signalling, if you think on; hence the (heavy) adaptive prose.
Gaining knowledge and lore, locations and objects’s descriptions changes in light of the understanding of the world.

This debate ought to be continued in general programming/designing…

Best regards from Italy,
dott. Piergiorgio.