intfiction.org

The Interactive Fiction Community Forum
It is currently Mon May 21, 2018 3:24 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Mon Feb 12, 2018 7:23 am 
Offline

Joined: Sun Feb 11, 2018 7:25 pm
Posts: 3
Hello,

I am very new to TADS 3, and am wondering how I can make objects change their descriptions and names depening on player actions.

A very simple example first; let's assume the PC holds the book to begin with.

> x book
The book is thick and leather bound, with gilded letters on its spine.

> read spine
Hermetica.

> x book
The book is thick and leather bound, the gilded letters on the spine read Hermetica.

And similarly, the object's name.

> drop hermetica
Dropped.

> look
...and Hermetica lies on the floor.

That is, not only can the description change according to PC actions, but the game refers to (some subset of) objects according to which synonym the player typed in, from that point on.

Can this be done at all, with TADS 3?


Top
 Profile Send private message  
Reply with quote  
PostPosted: Mon Feb 12, 2018 10:10 am 
Offline

Joined: Sat Jul 16, 2011 3:48 pm
Posts: 279
Anything can be done in TADS :-) Yes, you can variate text descriptions, there is a special syntax for embedding conditionals in strings, like:

Code:
book: Thing 'book/spine' 'book'
    "The book is thick and leather bound, <<if gRevealed('book-spine')>>the gilded letters
    on the spine read Hermetica. <<else>>with gilded letters on its spine. "
;

Then you just add tag <.reveal book-spine> to your read description of spine object. See chapter 7.1.3 of Learning TADS 3 for revealing and end of chapter 4.4 for special things you can put into strings.

You can also change the name of an object, it's a property called name (and few others derived from name), preferably see examples how to change name of Actors in manual, which is similar. And you can also change vocabulary dynamically (there are special methods for that, changing vocabWords is not enough for that), but that is more advanced.


Last edited by tomasb on Mon Feb 12, 2018 12:30 pm, edited 1 time in total.

Top
 Profile Send private message  
Reply with quote  
PostPosted: Mon Feb 12, 2018 12:15 pm 
Offline

Joined: Sun Mar 01, 2009 8:02 pm
Posts: 1618
With the adv3 library, which is standard T3, the cmdDict() method is used to change vocabulary. I don't remember where it's documented -- it's a bit obscure, but it does work. (In adv3lite, other methods are used to get this result.)


Top
 Profile Send private message  
Reply with quote  
PostPosted: Mon Feb 12, 2018 1:11 pm 
Offline
User avatar

Joined: Tue Apr 20, 2010 2:48 pm
Posts: 984
Location: Greece
If you want to add additional vocabulary to an object (for example, because the player now knows more information about the object), you can just call initializeVocabWith(). For example, when the player reads the spine and "Hermetica" is revealed to the player, you can do:

Code:
readDesc()
{
    "Hermetica. ";
    book.initializeVocabWith('hermetica');
}


Note that this adds vocabulary. It does not replace it. The existing vocabulary ("book", etc) will continue to work. Also, duplicates are cleaned up automatically. So in the above code, you don't have to check if you already added "hermetica" to the vocabulary.

The string you pass to initializeVocabWith() uses the same syntax as normal vocabWords strings. That is, "adj adj noun/noun*plural plural".

_________________
@realnc


Top
 Profile Send private message  
Reply with quote  
PostPosted: Mon Feb 12, 2018 8:23 pm 
Offline

Joined: Sun Feb 11, 2018 7:25 pm
Posts: 3
Ok, first the success story.

The code so far.
Code:
library: Room 'Library'
    "The library is filled with books. "
;

+ Fixture 'desk' 'desk'
    "The desk is ornately carved. "
;

++ tarzan1: Thing 'leather bound book/volume' 'book'
    "It's a leather bound volume with flourished gilded letters on the
    spine<< if gRevealed('tarzan1-spine') >> which read <q>Tarzan of the Apes</q><< end >>. "
;

+++ spine: Readable, Component 'gilded flourished flowery curved letters/spine/shapes' 'spine'
    "The letters on the spine are intricately curved in various flowery shapes
    << if gRevealed('tarzan1-spine') >> which read <q>Tarzan of the Apes</q><< end >>. "
    readDesc() {
        "The letters are hard to read, but you make out <q>Tarzan of the Apes.</q>";
        gReveal( 'tarzan1-spine' );
        tarzan1.name = 'Tarzan of the Apes';
        tarzan1.isQualifiedName = true;
    }
;


Which results in pretty much what I want.

Quote:
Library
The library is filled with books.

The desk contains a book.

>x book
It's a leather bound volume with flourished gilded letters on the spine.

>x spine
The letters on the spine are intricately curved in various flowery shapes .

>read spine
The letters are hard to read, but you make out “Tarzan of the Apes.”

>x book
It's a leather bound volume with flourished gilded letters on the spine which read “Tarzan of the Apes”.

>x desk
The desk is ornately carved. It contains Tarzan of the Apes.


However, this is where it fails.

Quote:
>open book
That is not something you can open.

>read tarzan of the apes
The word “tarzan” is not necessary in this story.

(If this was an accidental misspelling, you can correct it by typing
OOPS followed by the corrected word now. Any time the story
points out an unknown word, you can correct a misspelling using
OOPS as your next command.)


Of course I want the book to be openable -- otherwise it makes no sense (to me).

And, to make it possible to refer to the book by name (preferably only after the name has been discovered) I tried this, adapted from something I found on the 'net.

Code:
grammar qualifiedSingularNounPhrase(tarzan1):
    'tarzan' 'of' 'the' 'apes'
    : SpecialNounPhraseProd
    getMatchList = [tarzan1]
    getAdjustedTokens =
      ['tarzan', &noun, 'of', &miscWord, 'the', &miscWord, 'apes', &noun]
;


However, it fails with this error message:
Code:
The symbol "SpecialNounPhraseProd" is undefined.  This symbol is used as a
superclass in the definition of the object
"qualifiedSingularNounPhrase(tarzan1)".  Check the object definition to ensure
that the superclass name is spelled correctly, and check that the superclass's
object definition is correct.


Am I using it wrong? Or is this some obsolete feature that's no longer relevant?

How do I make the phrase "Tarzon of the Apes" refer to the book?

How do I make the book openable, and subsequently readable?


Top
 Profile Send private message  
Reply with quote  
PostPosted: Mon Feb 12, 2018 10:55 pm 
Offline

Joined: Sun Feb 11, 2018 7:25 pm
Posts: 3
Ok, apparently I don't need the complex noun phrase in the grammar; at least not immediately, so I'm leaving that for later.

It is sufficient to
Code:
tarzan1.initializeVocabWith( 'tarzan of the apes' );


and then I can
Quote:
>read tarzan of the apes
It's a leather bound volume with flourished gilded letters on the spine which read “Tarzan of the Apes”.


The next exercise is to make it some sort of a readable object, that requires opening before it can be read.

Later on I hope I can make it a container for thin objects, like a sheet of paper or a bookmark.

EDIT: If I just make it a OpenableContainer then I can't read the spine without opening it first. I guess that's the first hurdle to overcome; separate the "inside" of it from the "outside."


Top
 Profile Send private message  
Reply with quote  
PostPosted: Tue Feb 13, 2018 12:48 pm 
Offline

Joined: Sun Mar 01, 2009 8:02 pm
Posts: 1618
myrkraverk wrote:
EDIT: If I just make it a OpenableContainer then I can't read the spine without opening it first. I guess that's the first hurdle to overcome; separate the "inside" of it from the "outside."

You can do this by making it a complex container. Look at the page for ComplexContainer in the Tour Guide.


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group