Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[TADS3] Question regarding "modify Thing"

9 views
Skip to first unread message

Ken

unread,
Oct 25, 2005, 10:29:46 AM10/25/05
to
Howdy Y'all,

Got a question here. Can I add my own customizations to Item
descriptions using a "modify Thing" method just as I can to Room
descriptions with "modify Room?"

I have banners that get their contents from a variable that can be set
from within Room objects to display a Room picture.

What I want to do is be able to use the same kind of modify method on
other objects besides Rooms so that when any object is examined a
corresponding picture will appear in the banner window.

All I really need to know is - what is wrong, if anything, with my
custom modify Thing method below and, if wrong, what can I do to make
it do what I want it to do. Just assume the banner code works (because
it does) and focus on the modify Thing issue if you don't care. Thanks.


I know this works like a charm:

modify Room
roomDesc()
{
leftBanner.display(roomPic);
rightBanner.display(roomAction);
inherited;
}
;

But what about this?

modify Thing
itemDesc()
{
leftBanner.display(itemPic);
rightBanner.display(itemSpecs);
inherited;
}
;

Do I need to define a special "dobjFor(examine)" method in this Thing
modification to make it work when the thing is examined? What about
when inventory is called up - could I have a bunch of pictures be shown
instead of just a list of names?

Greg Boettcher

unread,
Oct 26, 2005, 3:38:35 AM10/26/05
to

I'll take a crack at this. I'm not quite an expert-level TADS 3
programmer, but I've worked with banners and might be able to help you.

First of all, I don't know where you got "itemDesc" from. Change it to
"desc" instead; there is no "itemDesc" in TADS 3.

Secondly, I'm surprised that the modify Room thing is working for you.
Wouldn't any room with a roomDesc property override what you have and
make it moot? I must be missing something here.

Personally, in the game I'm working on, I usually call up room-based
banner graphics in the room's enteringRoom routine. It works
beautifully, and doesn't interfere with the roomDesc property (and I
don't have to worry about whether the player is playing in verbose mode
or not). This may or may not suit your needs.

If you change "itemDesc" and it still doesn't work for you, I would
suggest trying out some changes to dobjFor(Examine) for the Thing
class, as you said.

If you want to do something really different as a response to
"inventory," then here's one way to do it:

replace VerbRule(Inventory)
'i' | 'inventory' | 'take' 'inventory'
: PictureInventoryAction
verbPhrase = 'take/taking inventory'
;

DefineIAction(PictureInventory)
execAction()
{
// Add your code here.
}
;

I haven't tested that, but I think it would work.

Greg

Ken

unread,
Oct 26, 2005, 4:17:36 AM10/26/05
to
Thanks for the crack Gregg. ;)

I'll try the inventory thing once I get a few other things straightened
out. Here is how I am handling all my banner pictures now. This sets up
a topaligned parent banner split down the middle by a left aligned
child banner. I use the leftbanner for room and item pictures and the
rightbanner for various things such as brief action messages [like
KABOOM! to go with an explosion graphic and eventually I plan on using
a BardsTale style combat message sequence there too] or such as a menu
of hyperlinked commands. I'd like to also figure out how to show topic
reponse lists there as well.

leftBanner: BannerWindow
initBannerWindow() {
inherited();
showBanner(nil, BannerLast, nil, BannerTypeText,
BannerAlignTop,
nil, nil, BannerStyleBorder);
}

/* print the material to the banner */
display(graphx) {
flushOutput();
leftBanner.initBannerWindow();
leftBanner.clearWindow();
local previousStream = leftBanner.setOutputStream();
"<BODY BGCOLOR=BLACK><img src=\"<<graphx>>.jpg\">";
leftBanner.flushBanner();
leftBanner.sizeToContents();
outputManager.setOutputStream(previousStream);
}
;

rightBanner: BannerWindow
initBannerWindow() {
inherited();
showBanner(leftBanner, BannerLast, nil, BannerTypeText,
BannerAlignRight,
50, BannerSizePercent, BannerStyleBorder);
}

/* print the material to the banner */
display(text) {
flushOutput();
rightBanner.initBannerWindow();
rightBanner.clearWindow();
local previousStream = rightBanner.setOutputStream();
"<<text>>";
rightBanner.flushBanner();
outputManager.setOutputStream(previousStream);
}
;

Then I can place the following two lines anywhere in my code to create
an explosion effect or whatever I need...

leftBanner.display('explosion');
rightBanner.display('KABOOM!');

I was using the following code which saves a little typing if all you
want are room pictures and associated action text or links. I'll show
an example.

modify Room
roomDesc()
{
leftBanner.display(roomPic);
rightBanner.display(roomAction);
inherited;
}
;

Then it is just a matter of assigning the appropriate values to roomPic
and roomAction:

tvRoom : Room 'Living Room' 'the living room'
"You are in the living room. "
roomPic = 'tvRoom' /* assuming you have a file called tvRoom.jpg in the
sourcefile dir. */
roomAction = '<A HREF=\"help\">Help</A>\b
<A HREF=\"hint\">Hint</A>\b
<A HREF=\"i\">Inventory</A>\b
<A HREF=\"watch tv\">Watch TV</A>\b
etc...'
;

I don't have any trouble with any of the above code at all.

Ken

unread,
Oct 26, 2005, 4:35:17 AM10/26/05
to

Greg Boettcher wrote:

> First of all, I don't know where you got "itemDesc" from. Change it to
> "desc" instead; there is no "itemDesc" in TADS 3.

Thank you for pointing that our Gregg that helped. I got tired of
pouring over all the reems of documentation I have printed out in
search of an answer to one little syntax problem I was having.


> Secondly, I'm surprised that the modify Room thing is working for you.
> Wouldn't any room with a roomDesc property override what you have and
> make it moot? I must be missing something here.

Well the banner methods I am using switch the output stream when
writing to banners and then switch it back again so the inherited room
description behaviour can do its work as usual. Hope I am understanding
correctly how all this works. Truthfully I am sort of flying by the
seat of my pants here without a whole lot of a clue as to what I am
really doing. lol. I owe it all to the answers I have recieved here on
Google. I would especially like to thank Eric Eve and Steve Breslin for
their many valuable responses to my questions and for all the work they
have done to make TADS3 more digestable for the masses. ;)

--Ken

Ken

unread,
Oct 26, 2005, 5:28:54 AM10/26/05
to
Well. I tried changing what I had "itemDesc" to Desc and it didnt work
with the "()" at the end or without it. I also tried the following and
still no go.

modify Thing
dObjFor(look) // and I tried Look examine Examine too
{
leftBanner.display(itemPic);
rightBanner.display(itemSpecs);
inherited;
}

Krister Fundin

unread,
Oct 26, 2005, 7:23:26 AM10/26/05
to

"Ken" <conta...@frontiernet.net> skrev i meddelandet
news:1130318934.7...@z14g2000cwz.googlegroups.com...

Modifying "desc" won't work, since every object usually overrides
it with its own description. (Modifying "roomDesc" DOES work
though, since it just calls "desc" by default.) The above code should
work if you change it to "dobjFor(Examine)", and also put
everything in an "action()" block. You could try this too:

modify Thing
examineStatus()
{
inherited();
// do the rest here
}
;

This way, no picture is displayed if the object is distant or obscured
or something like that. Depending on how pedantic you are, you
might also want to check if gActor == gPlayerChar.

-- Krister Fundin

Nikos Chantziaras

unread,
Oct 26, 2005, 10:57:42 PM10/26/05
to
Ken wrote:
> Howdy Y'all,
>
> Got a question here. Can I add my own customizations to Item
> descriptions using a "modify Thing" method just as I can to Room
> descriptions with "modify Room?"

You can add or even override whatever you like with 'modify'.


> I know this works like a charm:
>
> modify Room
> roomDesc()
> {
> leftBanner.display(roomPic);
> rightBanner.display(roomAction);
> inherited;
> }
> ;

Room.roomDesc() is actually BasicLocation.roomDesc(); Room inherits this
method from BasicLocation. If you want your code to work with other
types of locations and not just Room, you should 'modify BasicLocation'.
Also, it might be a good idea to check if a roomPic and roomAction
actually exists before displaying it:

modify BasicLocation
roomPic = nil
roomAction = nil
roomDesc()
{
if (self.roomPic != nil) leftBanner.display(roomPic);
if (self.roomAction != nil) rightBanner.display(roomAction);
inherited;
}
;

You can fine-tune this even further. For example, if you're in a nested
room that lacks a roomPic, you could display the containg room's picture
instead. You would also modify NestedRoom for this to work.


> But what about this?
>
> modify Thing
> itemDesc()
> {
> leftBanner.display(itemPic);
> rightBanner.display(itemSpecs);
> inherited;
> }
> ;

Since you've put an 'inherited' there, you assume that 'Thing' already
defines an itemDesc() method. But this isn't the case. itemDesc()
isn't defined by the library at all; it's just a method defined by you.
It will never get called. (You can always do a brute-force search in
the adv3 directory to find out if an identifier exists; "grep" in Unix,
not sure about Windows).


> Do I need to define a special "dobjFor(examine)" method in this Thing
> modification to make it work when the thing is examined?

It's best not to mess with action handlers if you can avoid it. The
default dobjFor(Examine) implementation in Thing calls the
Thing.mainExamine() method, so mainExamine() is all you need to modify.
For example:

modify Thing
itemPic = nil
itemSpecs = nil
mainExamine()
{
if (self.itemPic != nil) leftBanner.display(itemPic);
if (self.itemSpecs != nil) rightBanner.display(itemSpecs);
inherited;
}
;


> What about when inventory is called up - could I have a bunch
> of pictures be shown instead of just a list of names?

That's the easy part. Just customize the showInventory() method of the PC.

And a little tip to sum it up: when you find yourself wondering how to
do something, just act as if you were using Google; search for relevant
strings in the adv3 sources. When you find something that seems to be
relevant but isn't quite what you're searching for, follow the thread of
method calls. Sooner or later you'll hit the right one.

Nikos Chantziaras

unread,
Oct 26, 2005, 11:39:38 PM10/26/05
to
Ken wrote:

> Greg Boettcher wrote:
>> Secondly, I'm surprised that the modify Room thing is working for you.
>> Wouldn't any room with a roomDesc property override what you have and
>> make it moot? I must be missing something here.
>
> Well the banner methods I am using switch the output stream when
> writing to banners and then switch it back again so the inherited room
> description behaviour can do its work as usual.

What Greg actually meant, is that whenever an *object* defines roomDesc,
your code won't work anymore for that object. (I hope you know the
difference between a class and an object?)


> Hope I am understanding
> correctly how all this works. Truthfully I am sort of flying by the
> seat of my pants here without a whole lot of a clue as to what I am
> really doing. lol.

You can't learn anything about something without first breaking it...

Nikos Chantziaras

unread,
Oct 26, 2005, 11:44:37 PM10/26/05
to

This is related to my previous post, where I said:

"Whenever an *object* defines roomDesc, your code won't work anymore for

that object. (I hope you know the difference between a class and an
object?)"

This is exactly what happens here. Although you try to modify the
desc() method in the Thing class, each *object* of class Thing specified
its own desc(), so your changes don't have any effect.

I mentioned mainExamine() in another post, which should do the job.

Also, it's "desc", not "Desc". Keep in mind that only class names are
capitalized; normal methods/properties aren't.

Ken

unread,
Oct 27, 2005, 8:09:05 AM10/27/05
to
Nikos,

Invaluable information. Thank you!

Regarding Google do you mean like Domain specific searches but
restricted to a local directory on my computer rather than online? I'm
not sure how to do that. That would be extremely useful though!

I've been trying to find stuff using the docgen proto-documentation
someone created for TADS3 but I am having alot of trouble navigating
it. I don't see how people find it so useful. For one example - I've
been trying to find relevant info on the proper syntax and the
programming rules for writing your own functions [not the anonymous
kind which I found documented elsewhere] but haven't been able to find
anything related to writing functions.

I am familiar with the difference between an object and a class
although I havent done much experimentation writing or modifying
classes yet, other than what I was instructed to do in Eric's Golden
Banana Tutorial. Theres alot of stuff in there I need to go back and
fiddle with some more to make sure I've retained it all to some degree.
For me it takes alot of repetition to really gain retention when it
comes to programming. Anyway, I really appreciate all your help.

Ken

unread,
Oct 27, 2005, 8:09:11 AM10/27/05
to

Ken

unread,
Oct 27, 2005, 8:21:20 AM10/27/05
to
I forgot to thank you too Krister. Your instruction has been
enlightening as well. Thank you sir!

I hope eventually all this will start to sink in and some kind of
overall understanding emerges so that I will be able to give as much
back to the TADS3 community as you all have given me.

--Ken

Ken

unread,
Oct 27, 2005, 9:11:00 AM10/27/05
to
Hooray! This worked beautifully. Thanks Krister.

modify Thing
examineStatus()
{
inherited();

leftBanner.display(itemPic);
rightBanner.display(itemSpecs);
}
dobjFor(Watch)
{
verify()
{
illogical('You watch {the dobj/he} for a little while but your

mind is on something else. ');
}
}
;

Now to try out the extras Nikos recommended.

--Ken

Krister Fundin

unread,
Oct 27, 2005, 3:39:55 PM10/27/05
to

"Ken" <conta...@frontiernet.net> skrev i meddelandet
news:1130414945.8...@o13g2000cwo.googlegroups.com...

>
> I've been trying to find stuff using the docgen proto-documentation
> someone created for TADS3 but I am having alot of trouble navigating
> it. I don't see how people find it so useful. For one example - I've
> been trying to find relevant info on the proper syntax and the
> programming rules for writing your own functions [not the anonymous
> kind which I found documented elsewhere] but haven't been able to find
> anything related to writing functions.
>

It's nothing fancy, really:

functionName(arg1, arg2)
{
// code
}

Just like a method definition, except that it's not in any object. For
some more info on the language itself, you should check out the
system documentation if you haven't already. It's available in the "doc"
subdirectory if you have the author's kit, or otherwise you can get it
from the TADS site.

As for the proto-documentation, it's just an extraction of the
comments in the adv3 library. I mostly do my research by reading
through the library files themselves. That way I can see exactly what
the code does.

-- Krister Fundin

Ken

unread,
Oct 27, 2005, 9:01:01 PM10/27/05
to
Thanks Krister. I finally figured it out after some guess work and
trial and error. What was throwing me off was how simple it is. I
thought there had to be some kind of declaration to it such as an
object name "function" as in function: myFunction or a class name such
as myFunction: function. I hadnt tried simply writing "myFunction()"
because I thought that form was reserved for actually executing the
function. Seems like I am often overlooking the simplicity of TADS3 by
assuming things are more complicated than they are.

Ken

unread,
Oct 27, 2005, 9:05:47 PM10/27/05
to
One thing about your use of the adv3 library. Do you have some method
of looking up what you want to reference in the library without having
to go through every dang file such as using Google somehow as has
already been suggested? I'd like to know how to do that or how you look
things up. All those library file names are meaningless to me. They
dont tell me anything about whats in them. So I end up having to open
each one and use "find" in the menu to see if it has what I am looking
for - and sometimes I am not sure exactly what to call what I am
looking for either.

--Ken

Nikos Chantziaras

unread,
Oct 28, 2005, 2:46:39 AM10/28/05
to
Ken wrote:
> One thing about your use of the adv3 library. Do you have some method
> of looking up what you want to reference in the library without having
> to go through every dang file such as using Google somehow as has
> already been suggested?

Uhm, I was not talking about actually using Google or anything like
that. I just meant that searching the adv3 library is somewhat similar
to using Google! :)

Search for some relevant keywords, and see in which files they appear.
Then refine the search and just follow the thread. That's all.


> I'd like to know how to do that or how you look
> things up. All those library file names are meaningless to me. They
> dont tell me anything about whats in them. So I end up having to open
> each one and use "find" in the menu to see if it has what I am looking
> for - and sometimes I am not sure exactly what to call what I am
> looking for either.

Well, I assume you're using Windows. I work with Linux, so I'm using
the "grep" utility. I just type-in a string, and the tool reports to me
in which files (and lines in these files) the string appears. Then I
just open the files in my editor and press Ctrl+F and search. I don't
know how to this in Windows. In Linux (and Unix in general), programmer
tools are available "out of the box"; they're available from the start,
without the need to install them manually.

And the filenames aren't that meaningless. "thing.t" is self
explanatory, I think. "travel.t", "actor.t" etc. are also easy to
figure out. But in the end, since I've searched them so many times, I
usually know right away where I have to search for something. That's
called "learning", I think... :)

Nikos Chantziaras

unread,
Oct 28, 2005, 2:51:37 AM10/28/05
to
Ken wrote:
> Thanks Krister. I finally figured it out after some guess work and
> trial and error. What was throwing me off was how simple it is. I
> thought there had to be some kind of declaration to it such as an
> object name "function" as in function: myFunction or a class name such
> as myFunction: function.

That's how it worked in Tads 2, by the way.


> I hadnt tried simply writing "myFunction()"
> because I thought that form was reserved for actually executing the
> function. Seems like I am often overlooking the simplicity of TADS3 by
> assuming things are more complicated than they are.

The new, simpler syntax, is inspired by the C programming language,
where you don't have to use a keyword to define functions. Tads 3 tries
to look like C more than anything else; with good reason, I think.
There are many C programmers out there. Learning Tads if you already
know C (or C++, for that matter), is really easy.

Eric Eve

unread,
Oct 28, 2005, 3:00:07 AM10/28/05
to
"Ken" <conta...@frontiernet.net> wrote in message
news:1130461546.9...@z14g2000cwz.googlegroups.com...

That's what the libdocs (protodocumentation) generated by docgen are
particularly useful for. You can click on a link to all (or most)
class names, object names, property names etc and it'll take you to
a relevant section of documentation taken from the library code
comments - but from there you can click on a link to take you to the
corresponding section of source code. That way you don't keep having
to each source file in turn.

-- Eric


Greg Boettcher

unread,
Oct 28, 2005, 4:18:37 AM10/28/05
to
Nikos Chantziaras wrote:
> > I'd like to know how to do that or how you look
> > things up. All those library file names are meaningless to me. They
> > dont tell me anything about whats in them. So I end up having to open
> > each one and use "find" in the menu to see if it has what I am looking
> > for - and sometimes I am not sure exactly what to call what I am
> > looking for either.
>
> Well, I assume you're using Windows. I work with Linux, so I'm using
> the "grep" utility. I just type-in a string, and the tool reports to me
> in which files (and lines in these files) the string appears. Then I
> just open the files in my editor and press Ctrl+F and search. I don't
> know how to this in Windows. In Linux (and Unix in general), programmer
> tools are available "out of the box"; they're available from the start,
> without the need to install them manually.

Here's how it is in Windows 2000. I think most other versions of
Windows have a similar feature, but you may have to experiment a bit.

Start -> Search -> For Files & Folders...

Where it says "Look in:", delete whatever is there and type the full
path of wherever your TADS 3 files are. It might be something like
"C:\Program Files\TADS 3\lib".

Put a value into the "Containing text:" field to search for whatever
you want.

When you're done, make sure to do one more thing. Keep the "Look in:"
field set to the TADS 3 directory, then make sure the other two fields
-- "Search for files or folders named:" and "Containing text:" -- are
blank. Click Search. You should see all the files in the TADS 3
library. Not so valuable in itself, but...

Now, in that same window, do File -> Save search. Save the search to a
place where you can easily find it again. Maybe the desktop. From that
point on, you can always click on that saved search and fill in the
blank to search the TADS 3 library.

Greg

Ken

unread,
Oct 28, 2005, 11:24:05 AM10/28/05
to
Thanks Greg. I'll try that. I'm using XP but I can see by your
instructions that XP is not significantly different from 2000 with
regards to the Search tool. Normally I am pretty Windows saavy believe
it or not, but when it comes to applying what I know to making my TADS
education a little more efficient I seem to lapse back into a computer
illiterate state on occasion.

--Ken

0 new messages