Using Tags, Variables, Canstants. etc. in TADS3

If you remember AGT, MAGX and so forth, You will recall that they used many tags, constants, variables and such that you could use/check/alter with every command/turn in the game. I’m talking about such things as ‘food left’, ‘time to rest’, defining treasure points and things and so on.

I’m just starting to write my TADS3 IF game and would like to know how these are employed in that language. I have been reading the TADS3 manuals like crazy to determine various uses of macros and such but still seem to need lots of help. Can anyone offer some help in this regard. :question:

What are the best extensions, source files. games and so forth to give me some ideas. :question:

For the most part, you shouldn’t need to mess with macros. Each of the items you’ve mentioned would normally be defined as a property of an object.

To start with foodLeft, I’m not sure what object you’d want that to apply to, as food items are more likely to be individual objects. You might want something like this (untested):

breadLoaf: Food 'loaf bread' 'loaf of bread' bitesRemaining = 5 dobjFor(Eat) { action () { bitesRemaining = bitesRemaining - 1; if (bitesRemaining == 0) { moveInto(nil); "You wolf down the last of the bread. "; } else "You tear off a hunk of bread and eat it. "; } } // etc.
The me object is an object just like any other, so you can easily give it a daemon that counts down a timeToRest property and nags the player in increasingly strident terms as that property approaches zero.

When you can’t think of a specific place to put a property, one possibility is to add it to libGlobal.

modify libGlobal
    foodCt = 200
;

If I do something like that, I also define a macro alias in the game’s .h file.

#define gFoodCt   (libGlobal.foodCt)

Then it’s just a matter of assigning the updated value to that property whenever it is recalculated.

Adv3 has some infrastructure for scoring; I recommend using Achievement objects - they are quite handy! For “every turn” stuff, you can set up a Daemon to run your calculations.

I did some of this stuff in my T3 port of ToaURoD (the Inform 7 homebrew adventure kit for Treasures of a Slaver’s Kingdom). You’re welcome to look at that source code if you think it would help.

Thanks a million for the help. It’s all (TADS3) starting to make sense. All of the different coding examples I’ve received over the last few days have been invaluable. :smiley:

RonG

I tried looking for the T3 Port of ToaURod but wasn’t quite sure what I should be downloading. My philosophy of life is now “Never get old.” I need a hint about this. :cry:

RonG

You can get it here:
dl.dropbox.com/u/2759298/toaurod_t3.zip

I need to do a final polish on the code at some point soon. It was my first sustained effort with T3 and I expect that comes through in parts. (Also I was in the middle of a love affair with very long lines. It ended badly and I would prefer to forget.)

My goal was not so much to produce a game; rather, I wanted to end up with a library (wrapping adv3) that would make it easy to produce homebrew ToaSK adventures.

Hence the source code organization:

  • toaurod.h defines templates and macros for convenience
  • toaurod.t handles the basic game logic and turn rules
  • commands.t deals with verbs
  • strings.t contains virtually all the printed text
  • world.t sets up the sample scenario

Ideally an author would only need to modify world.t (to add places, NPCs, and scenes) and he’d be off and running. But there’s quite a lot happening under the hood to make it all come together.

Together with the original code, this is the largest work of IF written in both Inform 7 and TADS 3. So it works on some level as a Cloak of Darkness writ large, though that wasn’t the motivation in either case.

I found, downloaded and have been examining toaurod. I’m very impressed with all of it. A heck of a lot of thought and work must have gone into this.

Once again, I thank all of you for your help.

RonG