Secret Door

Good Evening!! This is noob with another noob question

I make code that looks like this

shelf: SecretDoor 'Book Shelf' 'shelf' @StudyRoom " <<isOpen ? 'A large shelf that reveal secret stair down below ' : 'A large shelf with lots of book'>> . " dobjFor(Push) { verify() {} action() { makeOpen(!isOpen); "The shelf slide aside revealing stairs leading to bottom. "; } }

the plan is I want make shelf that when u put Book it will slide open

StudyRoom: Room 'Mansion Study Room'
    
    desc()
        {
    }

    north : OneWayRoomConnector
        {
             ->Stair1 
          canTravelerPass (traveler) { return shelf.isPush; } 
          explainTravelBarrier (traveler)  
            { " The shelf is blocking the way"; } 

        }
;    

two problem from this is in first code I only know how to “push” shelf not to place item in there so the shelf will move

second is eventhough I make this code the player still available to go north and when i put travelbarrier, the shelf still won’t moved. I know there are something wrong with my codes but i can’t pinpoint it! Can somebody help me?? thank u in advance and sorry for my poor english.
[size=150]
UPDATE[/size]

I manage to change the code and succesfull to push shelf but i still need to place item so the shelf can move not being pushed this is the revised code that i used

[code]shelf: SecretDoor ‘Book Shelf’ ‘shelf’
@StudyRoom
" <<isOpen ? 'A large shelf that reveal secret stair down below ’
: ‘A large shelf with lots of book’>> . "

dobjFor(Place)
{

action()

    {

if (book1.location == shelf)

  makeOpen(!isOpen);
  "The shelf slide aside revealing stairs leading to bottom. ";
       inherited; 
  achievement.awardPointsOnce(); 

}
 else
            {"There is slot fit for something in the shelf."}   

}
achievement : Achievement { +3 “Open Secret Door” }
; [/code]

But i still find error… Can anybody help??

First, there is no Place action. You want the PutOn action.

Second, I’m not sure whether a SecretDoor can also be a Surface (an object that you can put things on). You can try making a single object that inherits from both these classes – that might work. Alternatively, you might try making a separate shelf object (a Surface) that is a Component of the SecretDoor.

I bit overwhelm… I dunno how to make surface that able to make door open… Like what Master Jim Aikin said… I tried to make alternative surface with this code:

[code]shelf: SecretDoor ‘Book Shelf’ ‘shelf’
@StudyRoom
" <<isOpen ? 'A large shelf that reveal secret stair down below ’
: ‘A large shelf with lots of book’>> . "
cannotEnterMsg = ‘Seriously… What the hell I am thinkin…’
dobjFor(Place)
{

action()

    {

   
  makeOpen(!isOpen);
  "The shelf slide aside revealing stairs leading to bottom. ";
       inherited; 
  achievement.awardPointsOnce(); 

}
 else
            {"There is slot fit for something in the shelf."}   

}
;

shelf1: Surface ‘Book Shelf’ ‘shelf’
@StudyRoom
" <<isOpen ? 'A large shelf that reveal secret stair down below ’
: ‘A large shelf with lots of book’>> . "

dobjFor(PutOn)
{

action()

    {

if (book1.location == shelf)

  makeOpen(!isOpen);
  "The shelf slide aside revealing stairs leading to bottom. ";
       inherited; 
  achievement.awardPointsOnce(); 

}
 else
            {"There is slot fit for something in the shelf."}   

}
achievement : Achievement { +3 “Open Secret Door” }
;
;[/code]

Then lots of error poped… I’m really dunno how I can make some mechanism to unlock door via surface… any suggestion??

Well, TADS 3 is not the easiest programming language to learn. You may want to start by going through the Getting Started Guide and entering all the code in the example games. I have the sense that you’re starting out by tackling some fairly complex programming tasks – and you may end up getting discouraged.

I can’t provide code for all of the problems you may run into while working on your game, but I took the trouble to work my way through your secret door puzzle, because I needed the practice. Here’s the code that I came up with:

[code]Study: Room ‘Study’
"The north wall of the study is dominated by a sturdy-looking floor-to-ceiling
bookcase<<shelfDoor.isOpen ? ‘, which has opened outward to reveal a passageway’ : ‘’>>. "
north = shelfDoor
;

  • me: Actor
    ;

++ poetryBook: Readable ‘fat poetry Emily Dickinson/book’ ‘poetry book’
"A fat book containing the poems of Emily Dickinson. "
readDesc = "You've never cared much for poetry. "
;

++ banana: Thing ‘banana’ ‘banana’
;

  • shelfDoor: SecretDoor ‘’ ‘bookcase’
    “<<isOpen ? 'The bookcase has been opened to reveal a secret door! ’ : 'You see no door here. '>>”
    ;

++ shelf: Component, RestrictedSurface ‘(book) gap/shelf/case/bookcase/bookshelf’ ‘shelf’
"The bookcase is crammed with books. <<!poetryBook.isIn(self) ? ‘There's a gap where one of
the books seems to have fallen out.’ : ‘’>> "
validContents = [poetryBook]
iobjFor(PutOn) {
action() {
inherited();
"As you slide the book onto the shelf, the bookcase pivots outward with a massive
groan, revealing a secret door! ";
shelfDoor.makeOpen(true);
cmdDict.addWord(shelfDoor, ‘door’, &noun);
cmdDict.addWord(shelfDoor, ‘secret’, &adjective);
achievement.awardPointsOnce();
}
}
achievement: Achievement {+3 “opening the secret door”}
;

cellar: Room ‘Cellar’
“Congratulations – you’ve made it to the cellar. A staircase leads upward and ends
<<shelfDoorInside.isOpen ? 'at an open doorway. ’ : 'in a blank wall. '>>”
south = shelfDoorInside
up asExit (south)
;

  • shelfDoorInside: SecretDoor → shelfDoor ‘secret (blank) wall/door’ ‘secret door’
    “<<isOpen ? 'The secret door is open, revealing a gap. ’ : 'You see no door here. '>>”
    ;[/code]
    You may want to study this, as it illustrates several useful techniques. The shelf is a Component of the SecretDoor, and also a RestrictedSurface. Because it’s a RestrictedSurface, its only validContents is the poetryBook. (I included the banana for testing purposes.) The action part of iobj(PutOn) adds the words ‘secret’ and ‘door’ to the vocabulary for the SecretDoor – until that happens, the player can’t refer to it at all, because its list of vocabulary is empty.

A lot more could be done with this example to make it more realistic, but that should serve to get you started.

Also … I don’t know how to be polite about this, so I’ll just say it, and hope you’re not offended. If you hope to write a game that English speakers will enjoy playing, you’re going to need to learn more about the correct grammar of written English. I realize this is a lot to ask – learning T3 and also learning the finer details of English!

On the other hand, if you’re writing the game in some other language, and just translating your examples into basic English so we can see what you’re trying to do, then please say so. If that’s what you’re doing, I think people will be much more willing to help you with the code.

Hot Dang!! I’m so sorry for the trouble Master Jim! This helps me alot! And don’t worry about the other codes, my trouble is this pain in neck secret door, well thanks again…

Uhhh again I run into trouble… I planned to make secret door closed if player remove the book

here is the code

shelf: Component, RestrictedSurface '(book) gap/shelf/case/bookcase/bookshelf' 'Bookshelf'
@StudyRoom
    "Lots of literature and book gather by Mr Smithson place in here <<!book1.isIn(self) ? 
      'There\'s a small gap in bookshelf now, one of the book is fall from the place.' : ''>> "
    validContents = [book1]
    iobjFor(PutOn) {
        action() {
            inherited();
            "I put the book right between the gap and the shelf suddenly split into two revealing secret
            passageway.";
            shelfDoor.makeOpen(true);

            achievement.awardPointsOnce();
        }
    }
    achievement: Achievement {+3 "opening the secret door"}
        

;

book1: Readable 'Book' 'Book'

    "A odd looking book, with strange symbol just like the from the paper. "
    readDesc = "Nothing written in the book, just blank page. "
    
       dobjFor(Remove) {
        action() {
             if (location != shelf)
            inherited();
            "I take the book from the shelf and the shelf close in Instant.";
            shelfDoor.makeClose(true);

            
        }
    }
 
;

When i run the game, the player able to open the secret door but when I tried to remove the book the shelf won’t closed. Can somebody point my mistakes??

For one thing, there is no makeClose method. You want makeOpen(nil); You can learn this by looking in the Library Reference manual for the Door class.

Next, the way you’ve written it, inherited() is called ONLY if the book is not on the shelf, which means the command ‘remove book’ won’t work if the book is on the shelf.

Finally, if you use ‘take book’ or ‘take book from shelf’, that doesn’t trigger the Remove action, it triggers the Take action. Likewise, ‘remove book from shelf’ triggers the TakeFrom action, which in turn triggers the Take action.

A good way to find out what actions are triggered by what commands is to open en_us.t (in Workbench, if you’re using that) and search for the character string ‘remove’ – WITH the single quotation marks. If you’re using Workbench, you can use the Find dialog box and click the button for Entire Project. This will search everything, including en_us.t.

Thanks for the tip Master Jim! But I run a problem when I tried to use dObjfor (Take). I use remapping for remove so it become takefrom but when i remapping Take to become Takefrom, it just become “ordinary” Take here is my code

[code]iobjFor(TakeFrom) {

    action() {
    if (book1.location != shelf)
        inherited();
       
        shelfDoor.makeOpen(nil);
         "I take the book from the shelf and the shelf close in Instant.";
       
    }
}
iobjFor(Remove) remapTo(TakeFrom)
dobjFor(Take) remapTo (TakeFrom)[/code]

I also tried modify the book1 code so when it taken from the shelf it will close the shelf but it close everytime I “take” the book

[code]dobjFor(Take)

{

    action() {
    if
        (book1.location == shelf)
        inherited();
       
        shelfDoor.makeOpen(nil);
   
            "I take the book from the shelf and the shelf close in Instant.";
       
           
    }   
   
}[/code]

Any suggestion for this problem??

I could certainly fix the code you’re working on – that would be easy. But it wouldn’t actually solve the problem, because the problem you’re having is broader or deeper than the problems posed by this particular bit of code.

So I’m going to make a more general suggestion. Or actually, three of them.

First, you need to spend a few weeks working your way through the tutorials that teach how to use TADS 3. You need to start with the Getting Started Guide. After reading that, page by page, and working the examples, you will need to go on either to the Tour Guide or to the first half of Learning TADS 3.

What you will achieve by this is a more thorough understanding of how T3 works. There are also several important articles in the Technical Manual, such as the pages “Verify, Check, and When to Use Which” and “How to Create Verbs.” You’ll find references to Technical Manual articles sprinkled throughout Learning TADS 3. When you find a reference, you should go to that article and read it.

You may not understand everything you read, the first time you read it. T3 is a large, complex system, and you should expect to go back and forth among the documents numerous times as you develop a better familiarity with the system.

The second thing I would suggest is that you work on thinking logically. Computers are basically very, very stupid. They will do exactly what you tell them, which may not be at all what you mean. Here’s an example of code from your most recent post that illustrates the problem:

if (book1.location == shelf) inherited();
First, I imagine you know what inherited() does. It calls the library’s methods to do whatever the standard action is – in this case, for the player to pick up the book. But your logic is defective. Why? Because if the book is NOT on the shelf, inherited() will never be called. The result is, if the player uses the ‘take’ command when the book is not on the shelf, then (a) the shelf door will close anyway, because that line is NOT governed by the logic of the if line; and (b) the player will not end up holding the book.

Using curly braces to group your code statements and then thinking very carefully about exactly what you want to happen in various situations (and in what order) is really the ONLY way to catch this kind of problem. If you master the technique, your TADS authoring will be much more pleasant, and you’ll make progress more quickly with your game. If you don’t master the technique, chances are, you’ll never finish writing your game, because you’ll get too frustrated when things don’t work the way you want them to.

The third thing you need to learn is how to research. I’m pretty sure your example code misuses remapTo. I think what you want there is asIobjFor and asDobjFor. But I would have to research this point to be certain. The way I usually do this is by searching in Learning TADS 3 for the particular term I want to know about (in this case, remapTo). There’s bound to be some useful information in there.

The Library Reference Manual is also very useful for research, but I suspect it’s more difficult for a newcomer to understand. Take a look at the pages for the classes, and try clicking on the line numbers in the right margin.

I see… Hehe have done lot of research and do this and that since my last visit…

I got another question though, is there any method to make exits didn’t appear before we do certain command?? The bar that shown exit: north west up down on top left corner when we access TADS game, because if Exit were shown before player do specific command, it like a spoiler to the game… Thanks again…

The exits from a room are simply properties of the room object, such as south = Porch. You can create them when you create the room in your code, or you can assign them later, like this:

if (diningRoom.south == nil) { diningRoom.south = Arboretum; "Oh, wait -- there\'s a door in the south wall that you never noticed before. "; }