Modifying the library

I’ve been reading through alot of the TADS 3 help guides and it mentions modifying classes and verbs and pretty much anything in the library to suit your own needs, the only thing I haven’t found mention of is how permenant a change that is.

This may sound silly to alot of people but I can’t help but wonder if it’s changing the libary for just the game I’m working on or if it makes a permenant change to the standard library I’m using for example I might want to change “dropped…” to “{It dobj/he} fall{s} to the floor” or modify the actor class to suit whatever… When I start my next game I might want all the messages changed again and I certainly wouldn’t want all the modded behaviours. Can someone confirm to me that the library I’m using is specific to the project I’m working on or that the only code I should ever have to modify is in the source files (which is what I’ve been doing up until now)

Thanks

Modify only changes code in your project, not for the system as a whole. As long as you’re not actually editing one of the library files directly, there’s nothing to worry about.

modify Thing
    newProp = 'My new property'
;

If it helps, you can think of this as creating a new class called Thing1929348 that’s identical to the regular Thing in every way, but which now includes the changes you’ve made. Anything in your game that inherits from Thing will silently inherit from Thing1929348 instead.

You can modify the same object multiple times:

modify Thing
    newProp = 'My new property'
;

modify Thing
    newerProp = 'My newer property'
;

And it works like you’d want: the new Thing19293483 class silently replaces Thing, and is replaced in turn by the even newer Thing84757276 class. The resulting class has newProp and newerProp defined, as well as all of the other Thing properties.

(I do this all the time to keep small tweaks with the section of code that uses them.)

The only gotcha is if you modify the same object and override the same property in two modify statements.

modify Thing
    newProp = 'My new property'
;

modify Thing
    newProp = 'My brand-new property'
;

The result of this is going to be source-order dependent (last statement wins) or compilation-order dependent (last compiled file wins). It might still do what you expect, but it’s inherently fragile and best avoided.

Thank again, you’re pretty good at this :smiley:

That clears alot up for me, when it’s been mentioning about where the code is located (e.g. objects.t) I’ve been pondering alot over whether it meant to modify it in the actual source code… Out of interest is the same applicable to the include files, my understanding was that when you add the adv3 library that the include files is essentially a list of source files contained within (hence my reluctance to touch them) but I noticed last night that they get added to the obj folder where my project is located.

It’s not that I want to play with them, I’d much prefer to tweek things through my own source files, I’m just curious

By include files I assume you mean the headers specified with the #include directive, at the top of each source file.

These just provide common templates and macro definitions. For example, gPlayerChar is defined in adv3.h as:

#define gPlayerChar (libGlobal.playerChar)

You won’t want to modify any of the standard headers. I usually make my own header to handle templates and macros. For example:

#charset "utf-8"
#include <adv3.h>
#include <en_us.h>

/*
	Common templates and macros.
*/

Test template 'testName' [testList];

You can save that as “my.h” and then #include “my.h” instead of using the other two #include lines.

The actual code for stuff comes from the various .t files in the lib directory. On my PC, this is C:\Program Files (x86)\TADS 3\lib.

Anything that’s in one of those files can be modified or replaced by code in your own .t files, so there’s no reason to edit them unless you are fixing an actual bug in the standard library.

The compiler finds these files with a library (.tl) file. You can look at lib\adv3\adv3.tl or lib\adv3\en_us\en_us.tl to see what files a library includes.

I actually meant where it displays the .t files that are included in the Include Files tab on the left of the screen, when I was refering to the library earlier I was talking about the header files in the Source Files tab.

Sorry I think my terminology is a bit off, I got that when you write

it adds the header files at the top of the source files tab, they then then add the .t files to the include tab on the left, I just wasn’t sure if the .t files were relating to the ones that will compile in my game or if they’re relating to the actual standard library.

Obviously I wouldn’t want to play with the header files but what I meant was if I modify something in my own source code, is it the same as modifying it in the equivelent file include tab on the left?
Most of my tweeks so far have been object/class specific I’m just thinking about the workings of editing messages like ‘dropped’ and ‘taken’ or… I dunno off the top of my head. Modifying in my actual code clearly is the easier way, it’s just good to know what I’m actually changing if you get me. :slight_smile:

The .t files are the library. Using the modify keyword in your own code has the same effect as editing the .t files themselves – except that the .t files are not altered in any way.

This has two or three positive effects: First, they’ll be the same the next time you start a new game, so your modifications can be game-specific. Second, the documentation will remain a reliable guide to the library files. And third, if you create a bug, it will be in your own code, not in the library.

You can edit messages by modifying the files in msg_neu.t, or you can add specific messages to specific objects to customize their response to commands. I haven’t researched this, but I believe the library looks first to the specific object to determine if it defines a given message. If there’s nothing in that object, the library goes out and gets its standard message.

As Jim says, you can look at msg_neu.t to see what object defines the message you are modifying - usually playerMessages or playerActionMessages - and then modify that object in your code and override the property.

modify playerActionMessages
    okayTakeMsg = 'Looted. '
;

Oh ok… Cool that wasn’t the answer I was expecting, like I say I figured last night those files might have been relating to the ones that are copied, I’ll definately know not to play with them now, as for editing the player messages in msg_neu.t wouldn’t that make a permenant change too then?.. I’ll make a back up just in case if or when I try changing messages globally, and thanks for clearing that up for me too

You can use the modify keyword on the objects in msg_neu.t. This will modify the messages only in your current game.